From 2539c7510e20ba80fbaf8ca0e64e3386a539b257 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 18 May 2022 23:49:29 +0000 Subject: [PATCH 1/4] docs: fix docstring formatting Committer: parthea PiperOrigin-RevId: 449545643 Source-Link: https://github.com/googleapis/googleapis/commit/1bed8a0d6886720c5bfc8ba1076de3db68c23b83 Source-Link: https://github.com/googleapis/googleapis-gen/commit/d4ccc5fc612c260546bcecef2873575688a02d8b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDRjY2M1ZmM2MTJjMjYwNTQ2YmNlY2VmMjg3MzU3NTY4OGEwMmQ4YiJ9 --- owl-bot-staging/v2/.eslintignore | 7 + owl-bot-staging/v2/.eslintrc.json | 3 + owl-bot-staging/v2/.gitignore | 14 + owl-bot-staging/v2/.jsdoc.js | 55 + owl-bot-staging/v2/.mocharc.js | 33 + owl-bot-staging/v2/.prettierrc.js | 22 + owl-bot-staging/v2/README.md | 1 + owl-bot-staging/v2/linkinator.config.json | 16 + owl-bot-staging/v2/package.json | 69 + .../google/cloud/retail/v2/catalog.proto | 110 + .../cloud/retail/v2/catalog_service.proto | 246 ++ .../google/cloud/retail/v2/common.proto | 479 +++ .../cloud/retail/v2/completion_service.proto | 198 ++ .../cloud/retail/v2/import_config.proto | 394 +++ .../cloud/retail/v2/prediction_service.proto | 194 ++ .../google/cloud/retail/v2/product.proto | 558 ++++ .../cloud/retail/v2/product_service.proto | 822 +++++ .../google/cloud/retail/v2/promotion.proto | 40 + .../google/cloud/retail/v2/purge_config.proto | 79 + .../cloud/retail/v2/search_service.proto | 786 +++++ .../google/cloud/retail/v2/user_event.proto | 340 +++ .../cloud/retail/v2/user_event_service.proto | 190 ++ .../v2/catalog_service.get_default_branch.js | 58 + .../v2/catalog_service.list_catalogs.js | 83 + .../v2/catalog_service.set_default_branch.js | 81 + .../v2/catalog_service.update_catalog.js | 70 + .../v2/completion_service.complete_query.js | 116 + ...mpletion_service.import_completion_data.js | 73 + .../v2/prediction_service.predict.js | 161 + .../product_service.add_fulfillment_places.js | 115 + .../product_service.add_local_inventories.js | 99 + .../v2/product_service.create_product.js | 80 + .../v2/product_service.delete_product.js | 74 + .../v2/product_service.get_product.js | 65 + .../v2/product_service.import_products.js | 93 + .../v2/product_service.list_products.js | 130 + ...oduct_service.remove_fulfillment_places.js | 111 + ...roduct_service.remove_local_inventories.js | 85 + .../v2/product_service.set_inventory.js | 124 + .../v2/product_service.update_product.js | 80 + .../generated/v2/search_service.search.js | 260 ++ ...ippet_metadata.google.cloud.retail.v2.json | 1295 ++++++++ .../user_event_service.collect_user_event.js | 78 + .../user_event_service.import_user_events.js | 69 + .../user_event_service.purge_user_events.js | 90 + .../user_event_service.rejoin_user_events.js | 67 + .../v2/user_event_service.write_user_event.js | 64 + owl-bot-staging/v2/src/index.ts | 35 + .../v2/src/v2/catalog_service_client.ts | 1058 +++++++ .../src/v2/catalog_service_client_config.json | 55 + .../v2/src/v2/catalog_service_proto_list.json | 15 + .../v2/src/v2/completion_service_client.ts | 701 +++++ .../v2/completion_service_client_config.json | 45 + .../src/v2/completion_service_proto_list.json | 15 + owl-bot-staging/v2/src/v2/gapic_metadata.json | 345 +++ owl-bot-staging/v2/src/v2/index.ts | 24 + .../v2/src/v2/prediction_service_client.ts | 603 ++++ .../v2/prediction_service_client_config.json | 40 + .../src/v2/prediction_service_proto_list.json | 15 + .../v2/src/v2/product_service_client.ts | 2210 ++++++++++++++ .../src/v2/product_service_client_config.json | 99 + .../v2/src/v2/product_service_proto_list.json | 15 + .../v2/src/v2/search_service_client.ts | 1243 ++++++++ .../src/v2/search_service_client_config.json | 40 + .../v2/src/v2/search_service_proto_list.json | 15 + .../v2/src/v2/user_event_service_client.ts | 966 ++++++ .../v2/user_event_service_client_config.json | 78 + .../src/v2/user_event_service_proto_list.json | 15 + .../system-test/fixtures/sample/src/index.js | 32 + .../system-test/fixtures/sample/src/index.ts | 62 + owl-bot-staging/v2/system-test/install.ts | 49 + .../v2/test/gapic_catalog_service_v2.ts | 903 ++++++ .../v2/test/gapic_completion_service_v2.ts | 503 ++++ .../v2/test/gapic_prediction_service_v2.ts | 343 +++ .../v2/test/gapic_product_service_v2.ts | 1846 ++++++++++++ .../v2/test/gapic_search_service_v2.ts | 570 ++++ .../v2/test/gapic_user_event_service_v2.ts | 888 ++++++ owl-bot-staging/v2/tsconfig.json | 19 + owl-bot-staging/v2/webpack.config.js | 64 + owl-bot-staging/v2alpha/.eslintignore | 7 + owl-bot-staging/v2alpha/.eslintrc.json | 3 + owl-bot-staging/v2alpha/.gitignore | 14 + owl-bot-staging/v2alpha/.jsdoc.js | 55 + owl-bot-staging/v2alpha/.mocharc.js | 33 + owl-bot-staging/v2alpha/.prettierrc.js | 22 + owl-bot-staging/v2alpha/README.md | 1 + .../v2alpha/linkinator.config.json | 16 + owl-bot-staging/v2alpha/package.json | 71 + .../google/cloud/retail/v2alpha/catalog.proto | 397 +++ .../retail/v2alpha/catalog_service.proto | 478 +++ .../google/cloud/retail/v2alpha/common.proto | 761 +++++ .../retail/v2alpha/completion_service.proto | 199 ++ .../google/cloud/retail/v2alpha/control.proto | 92 + .../retail/v2alpha/control_service.proto | 184 ++ .../cloud/retail/v2alpha/export_config.proto | 77 + .../cloud/retail/v2alpha/import_config.proto | 397 +++ .../retail/v2alpha/prediction_service.proto | 194 ++ .../google/cloud/retail/v2alpha/product.proto | 567 ++++ .../retail/v2alpha/product_service.proto | 882 ++++++ .../cloud/retail/v2alpha/promotion.proto | 40 + .../cloud/retail/v2alpha/purge_config.proto | 171 ++ .../cloud/retail/v2alpha/search_service.proto | 832 ++++++ .../cloud/retail/v2alpha/serving_config.proto | 247 ++ .../v2alpha/serving_config_service.proto | 241 ++ .../cloud/retail/v2alpha/user_event.proto | 344 +++ .../retail/v2alpha/user_event_service.proto | 190 ++ .../catalog_service.add_catalog_attribute.js | 65 + .../catalog_service.get_attributes_config.js | 59 + .../catalog_service.get_completion_config.js | 59 + .../catalog_service.get_default_branch.js | 58 + .../v2alpha/catalog_service.list_catalogs.js | 83 + ...atalog_service.remove_catalog_attribute.js | 65 + ...talog_service.replace_catalog_attribute.js | 73 + .../catalog_service.set_default_branch.js | 81 + ...atalog_service.update_attributes_config.js | 67 + .../v2alpha/catalog_service.update_catalog.js | 70 + ...atalog_service.update_completion_config.js | 75 + .../completion_service.complete_query.js | 117 + ...mpletion_service.import_completion_data.js | 73 + .../v2alpha/control_service.create_control.js | 72 + .../v2alpha/control_service.delete_control.js | 59 + .../v2alpha/control_service.get_control.js | 59 + .../v2alpha/control_service.list_controls.js | 79 + .../v2alpha/control_service.update_control.js | 66 + .../v2alpha/prediction_service.predict.js | 161 + .../product_service.add_fulfillment_places.js | 115 + .../product_service.add_local_inventories.js | 100 + .../v2alpha/product_service.create_product.js | 80 + .../v2alpha/product_service.delete_product.js | 75 + .../v2alpha/product_service.get_product.js | 65 + .../product_service.import_products.js | 93 + .../v2alpha/product_service.list_products.js | 141 + .../v2alpha/product_service.purge_products.js | 101 + ...oduct_service.remove_fulfillment_places.js | 111 + ...roduct_service.remove_local_inventories.js | 85 + .../v2alpha/product_service.set_inventory.js | 124 + .../v2alpha/product_service.update_product.js | 80 + .../v2alpha/search_service.search.js | 281 ++ .../serving_config_service.add_control.js | 65 + ...ng_config_service.create_serving_config.js | 72 + ...ng_config_service.delete_serving_config.js | 59 + ...rving_config_service.get_serving_config.js | 59 + ...ing_config_service.list_serving_configs.js | 72 + .../serving_config_service.remove_control.js | 65 + ...ng_config_service.update_serving_config.js | 66 + ..._metadata.google.cloud.retail.v2alpha.json | 2187 ++++++++++++++ .../user_event_service.collect_user_event.js | 78 + .../user_event_service.import_user_events.js | 69 + .../user_event_service.purge_user_events.js | 91 + .../user_event_service.rejoin_user_events.js | 67 + .../user_event_service.write_user_event.js | 64 + owl-bot-staging/v2alpha/src/index.ts | 39 + .../src/v2alpha/catalog_service_client.ts | 1865 ++++++++++++ .../catalog_service_client_config.json | 90 + .../v2alpha/catalog_service_proto_list.json | 20 + .../src/v2alpha/completion_service_client.ts | 936 ++++++ .../completion_service_client_config.json | 45 + .../completion_service_proto_list.json | 20 + .../src/v2alpha/control_service_client.ts | 1195 ++++++++ .../control_service_client_config.json | 46 + .../v2alpha/control_service_proto_list.json | 20 + .../v2alpha/src/v2alpha/gapic_metadata.json | 581 ++++ owl-bot-staging/v2alpha/src/v2alpha/index.ts | 26 + .../src/v2alpha/prediction_service_client.ts | 837 ++++++ .../prediction_service_client_config.json | 40 + .../prediction_service_proto_list.json | 20 + .../src/v2alpha/product_service_client.ts | 2641 +++++++++++++++++ .../product_service_client_config.json | 104 + .../v2alpha/product_service_proto_list.json | 20 + .../src/v2alpha/search_service_client.ts | 1537 ++++++++++ .../v2alpha/search_service_client_config.json | 40 + .../v2alpha/search_service_proto_list.json | 20 + .../v2alpha/serving_config_service_client.ts | 1334 +++++++++ .../serving_config_service_client_config.json | 54 + .../serving_config_service_proto_list.json | 20 + .../src/v2alpha/user_event_service_client.ts | 1201 ++++++++ .../user_event_service_client_config.json | 78 + .../user_event_service_proto_list.json | 20 + .../system-test/fixtures/sample/src/index.js | 34 + .../system-test/fixtures/sample/src/index.ts | 74 + .../v2alpha/system-test/install.ts | 49 + .../test/gapic_catalog_service_v2alpha.ts | 1790 +++++++++++ .../test/gapic_completion_service_v2alpha.ts | 703 +++++ .../test/gapic_control_service_v2alpha.ts | 1108 +++++++ .../test/gapic_prediction_service_v2alpha.ts | 543 ++++ .../test/gapic_product_service_v2alpha.ts | 2190 ++++++++++++++ .../test/gapic_search_service_v2alpha.ts | 770 +++++ .../gapic_serving_config_service_v2alpha.ts | 1302 ++++++++ .../test/gapic_user_event_service_v2alpha.ts | 1088 +++++++ owl-bot-staging/v2alpha/tsconfig.json | 19 + owl-bot-staging/v2alpha/webpack.config.js | 64 + owl-bot-staging/v2beta/.eslintignore | 7 + owl-bot-staging/v2beta/.eslintrc.json | 3 + owl-bot-staging/v2beta/.gitignore | 14 + owl-bot-staging/v2beta/.jsdoc.js | 55 + owl-bot-staging/v2beta/.mocharc.js | 33 + owl-bot-staging/v2beta/.prettierrc.js | 22 + owl-bot-staging/v2beta/README.md | 1 + owl-bot-staging/v2beta/linkinator.config.json | 16 + owl-bot-staging/v2beta/package.json | 71 + .../google/cloud/retail/v2beta/catalog.proto | 397 +++ .../cloud/retail/v2beta/catalog_service.proto | 478 +++ .../google/cloud/retail/v2beta/common.proto | 760 +++++ .../retail/v2beta/completion_service.proto | 199 ++ .../google/cloud/retail/v2beta/control.proto | 84 + .../cloud/retail/v2beta/control_service.proto | 184 ++ .../cloud/retail/v2beta/export_config.proto | 77 + .../cloud/retail/v2beta/import_config.proto | 397 +++ .../retail/v2beta/prediction_service.proto | 194 ++ .../google/cloud/retail/v2beta/product.proto | 566 ++++ .../cloud/retail/v2beta/product_service.proto | 829 ++++++ .../cloud/retail/v2beta/promotion.proto | 40 + .../cloud/retail/v2beta/purge_config.proto | 80 + .../cloud/retail/v2beta/search_service.proto | 791 +++++ .../cloud/retail/v2beta/serving_config.proto | 247 ++ .../v2beta/serving_config_service.proto | 240 ++ .../cloud/retail/v2beta/user_event.proto | 342 +++ .../retail/v2beta/user_event_service.proto | 190 ++ .../catalog_service.add_catalog_attribute.js | 65 + .../catalog_service.get_attributes_config.js | 59 + .../catalog_service.get_completion_config.js | 59 + .../catalog_service.get_default_branch.js | 58 + .../v2beta/catalog_service.list_catalogs.js | 83 + ...atalog_service.remove_catalog_attribute.js | 65 + ...talog_service.replace_catalog_attribute.js | 73 + .../catalog_service.set_default_branch.js | 81 + ...atalog_service.update_attributes_config.js | 67 + .../v2beta/catalog_service.update_catalog.js | 70 + ...atalog_service.update_completion_config.js | 75 + .../completion_service.complete_query.js | 117 + ...mpletion_service.import_completion_data.js | 73 + .../v2beta/control_service.create_control.js | 72 + .../v2beta/control_service.delete_control.js | 59 + .../v2beta/control_service.get_control.js | 59 + .../v2beta/control_service.list_controls.js | 79 + .../v2beta/control_service.update_control.js | 66 + .../v2beta/prediction_service.predict.js | 161 + .../product_service.add_fulfillment_places.js | 115 + .../product_service.add_local_inventories.js | 100 + .../v2beta/product_service.create_product.js | 80 + .../v2beta/product_service.delete_product.js | 75 + .../v2beta/product_service.get_product.js | 65 + .../v2beta/product_service.import_products.js | 93 + .../v2beta/product_service.list_products.js | 132 + ...oduct_service.remove_fulfillment_places.js | 111 + ...roduct_service.remove_local_inventories.js | 85 + .../v2beta/product_service.set_inventory.js | 124 + .../v2beta/product_service.update_product.js | 80 + .../generated/v2beta/search_service.search.js | 261 ++ .../serving_config_service.add_control.js | 65 + ...ng_config_service.create_serving_config.js | 72 + ...ng_config_service.delete_serving_config.js | 59 + ...rving_config_service.get_serving_config.js | 59 + ...ing_config_service.list_serving_configs.js | 72 + .../serving_config_service.remove_control.js | 65 + ...ng_config_service.update_serving_config.js | 66 + ...t_metadata.google.cloud.retail.v2beta.json | 2131 +++++++++++++ .../user_event_service.collect_user_event.js | 78 + .../user_event_service.import_user_events.js | 69 + .../user_event_service.purge_user_events.js | 91 + .../user_event_service.rejoin_user_events.js | 67 + .../user_event_service.write_user_event.js | 64 + owl-bot-staging/v2beta/src/index.ts | 39 + .../src/v2beta/catalog_service_client.ts | 1865 ++++++++++++ .../v2beta/catalog_service_client_config.json | 90 + .../v2beta/catalog_service_proto_list.json | 20 + .../src/v2beta/completion_service_client.ts | 936 ++++++ .../completion_service_client_config.json | 45 + .../v2beta/completion_service_proto_list.json | 20 + .../src/v2beta/control_service_client.ts | 1195 ++++++++ .../v2beta/control_service_client_config.json | 46 + .../v2beta/control_service_proto_list.json | 20 + .../v2beta/src/v2beta/gapic_metadata.json | 571 ++++ owl-bot-staging/v2beta/src/v2beta/index.ts | 26 + .../src/v2beta/prediction_service_client.ts | 837 ++++++ .../prediction_service_client_config.json | 40 + .../v2beta/prediction_service_proto_list.json | 20 + .../src/v2beta/product_service_client.ts | 2455 +++++++++++++++ .../v2beta/product_service_client_config.json | 99 + .../v2beta/product_service_proto_list.json | 20 + .../src/v2beta/search_service_client.ts | 1480 +++++++++ .../v2beta/search_service_client_config.json | 40 + .../src/v2beta/search_service_proto_list.json | 20 + .../v2beta/serving_config_service_client.ts | 1333 +++++++++ .../serving_config_service_client_config.json | 54 + .../serving_config_service_proto_list.json | 20 + .../src/v2beta/user_event_service_client.ts | 1201 ++++++++ .../user_event_service_client_config.json | 78 + .../v2beta/user_event_service_proto_list.json | 20 + .../system-test/fixtures/sample/src/index.js | 34 + .../system-test/fixtures/sample/src/index.ts | 74 + owl-bot-staging/v2beta/system-test/install.ts | 49 + .../test/gapic_catalog_service_v2beta.ts | 1790 +++++++++++ .../test/gapic_completion_service_v2beta.ts | 703 +++++ .../test/gapic_control_service_v2beta.ts | 1108 +++++++ .../test/gapic_prediction_service_v2beta.ts | 543 ++++ .../test/gapic_product_service_v2beta.ts | 2046 +++++++++++++ .../test/gapic_search_service_v2beta.ts | 770 +++++ .../gapic_serving_config_service_v2beta.ts | 1302 ++++++++ .../test/gapic_user_event_service_v2beta.ts | 1088 +++++++ owl-bot-staging/v2beta/tsconfig.json | 19 + owl-bot-staging/v2beta/webpack.config.js | 64 + 302 files changed, 90409 insertions(+) create mode 100644 owl-bot-staging/v2/.eslintignore create mode 100644 owl-bot-staging/v2/.eslintrc.json create mode 100644 owl-bot-staging/v2/.gitignore create mode 100644 owl-bot-staging/v2/.jsdoc.js create mode 100644 owl-bot-staging/v2/.mocharc.js create mode 100644 owl-bot-staging/v2/.prettierrc.js create mode 100644 owl-bot-staging/v2/README.md create mode 100644 owl-bot-staging/v2/linkinator.config.json create mode 100644 owl-bot-staging/v2/package.json create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto create mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/search_service.search.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/v2/src/index.ts create mode 100644 owl-bot-staging/v2/src/v2/catalog_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/catalog_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/catalog_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/completion_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/completion_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/completion_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/gapic_metadata.json create mode 100644 owl-bot-staging/v2/src/v2/index.ts create mode 100644 owl-bot-staging/v2/src/v2/prediction_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/prediction_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/prediction_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/product_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/product_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/product_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/search_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/search_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/search_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/user_event_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/user_event_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/user_event_service_proto_list.json create mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v2/system-test/install.ts create mode 100644 owl-bot-staging/v2/test/gapic_catalog_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_completion_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_prediction_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_product_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_search_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_user_event_service_v2.ts create mode 100644 owl-bot-staging/v2/tsconfig.json create mode 100644 owl-bot-staging/v2/webpack.config.js create mode 100644 owl-bot-staging/v2alpha/.eslintignore create mode 100644 owl-bot-staging/v2alpha/.eslintrc.json create mode 100644 owl-bot-staging/v2alpha/.gitignore create mode 100644 owl-bot-staging/v2alpha/.jsdoc.js create mode 100644 owl-bot-staging/v2alpha/.mocharc.js create mode 100644 owl-bot-staging/v2alpha/.prettierrc.js create mode 100644 owl-bot-staging/v2alpha/README.md create mode 100644 owl-bot-staging/v2alpha/linkinator.config.json create mode 100644 owl-bot-staging/v2alpha/package.json create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/v2alpha/src/index.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/index.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v2alpha/system-test/install.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/tsconfig.json create mode 100644 owl-bot-staging/v2alpha/webpack.config.js create mode 100644 owl-bot-staging/v2beta/.eslintignore create mode 100644 owl-bot-staging/v2beta/.eslintrc.json create mode 100644 owl-bot-staging/v2beta/.gitignore create mode 100644 owl-bot-staging/v2beta/.jsdoc.js create mode 100644 owl-bot-staging/v2beta/.mocharc.js create mode 100644 owl-bot-staging/v2beta/.prettierrc.js create mode 100644 owl-bot-staging/v2beta/README.md create mode 100644 owl-bot-staging/v2beta/linkinator.config.json create mode 100644 owl-bot-staging/v2beta/package.json create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/v2beta/src/index.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/index.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v2beta/system-test/install.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/tsconfig.json create mode 100644 owl-bot-staging/v2beta/webpack.config.js diff --git a/owl-bot-staging/v2/.eslintignore b/owl-bot-staging/v2/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v2/.eslintrc.json b/owl-bot-staging/v2/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v2/.gitignore b/owl-bot-staging/v2/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v2/.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/v2/.jsdoc.js b/owl-bot-staging/v2/.jsdoc.js new file mode 100644 index 00000000..19729810 --- /dev/null +++ b/owl-bot-staging/v2/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v2/.mocharc.js b/owl-bot-staging/v2/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v2/.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/v2/.prettierrc.js b/owl-bot-staging/v2/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v2/.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/v2/README.md b/owl-bot-staging/v2/README.md new file mode 100644 index 00000000..822c4573 --- /dev/null +++ b/owl-bot-staging/v2/README.md @@ -0,0 +1 @@ +Retail: Nodejs Client diff --git a/owl-bot-staging/v2/linkinator.config.json b/owl-bot-staging/v2/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v2/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/v2/package.json b/owl-bot-staging/v2/package.json new file mode 100644 index 00000000..09d9ddf3 --- /dev/null +++ b/owl-bot-staging/v2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@google-cloud/retail", + "version": "0.1.0", + "description": "Retail client for Node.js", + "repository": "googleapis/nodejs-retail", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google retail", + "retail", + "catalog service", + "completion service", + "prediction service", + "product service", + "search service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto new file mode 100644 index 00000000..b5de698d --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto @@ -0,0 +1,110 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Configures what level the product should be uploaded with regards to +// how users will be send events and how predictions will be made. +message ProductLevelConfig { + // The type of [Product][google.cloud.retail.v2.Product]s allowed to be + // ingested into the catalog. Acceptable values are: + // + // * `primary` (default): You can ingest + // [Product][google.cloud.retail.v2.Product]s of all types. When + // ingesting a [Product][google.cloud.retail.v2.Product], its type will + // default to + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] if + // unset. + // * `variant`: You can only ingest + // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. + // This means + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] + // cannot be empty. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `variant` and + // [merchant_center_product_id_field][google.cloud.retail.v2.ProductLevelConfig.merchant_center_product_id_field] + // is `itemGroupId`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string ingestion_product_type = 1; + + // Which field of [Merchant Center + // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be + // imported as [Product.id][google.cloud.retail.v2.Product.id]. Acceptable + // values are: + // + // * `offerId` (default): Import `offerId` as the product ID. + // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail + // API will choose one item from the ones with the same `itemGroupId`, and + // use it to represent the item group. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `itemGroupId` and + // [ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] + // is `variant`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string merchant_center_product_id_field = 2; +} + +// The catalog configuration. +message Catalog { + option (google.api.resource) = { + type: "retail.googleapis.com/Catalog" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" + }; + + // Required. Immutable. The fully qualified resource name of the catalog. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The catalog display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. The product level configuration. + ProductLevelConfig product_level_config = 4 + [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto new file mode 100644 index 00000000..ec7a23a8 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto @@ -0,0 +1,246 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/catalog.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for managing catalog configuration. +service CatalogService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with + // the project. + rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/catalogs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates the [Catalog][google.cloud.retail.v2.Catalog]s. + rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { + option (google.api.http) = { + patch: "/v2/{catalog.name=projects/*/locations/*/catalogs/*}" + body: "catalog" + }; + option (google.api.method_signature) = "catalog,update_mask"; + } + + // Set a specified branch id as default branch. API methods such as + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search], + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + // will treat requests using "default_branch" to the actual branch id set as + // default. + // + // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + // default, setting + // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + // to setting + // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/1`. + // + // Using multiple branches can be useful when developers would like + // to have a staging branch to test and verify for future usage. When it + // becomes ready, developers switch on the staging branch using this API while + // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + // as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + // route the traffic to this staging branch. + // + // CAUTION: If you have live predict/search traffic, switching the default + // branch could potentially cause outages if the ID space of the new branch is + // very different from the old one. + // + // More specifically: + // + // * PredictionService will only return product IDs from branch {newBranch}. + // * SearchService will only return product IDs from branch {newBranch} + // (if branch is not explicitly set). + // * UserEventService will only join events with products from branch + // {newBranch}. + rpc SetDefaultBranch(SetDefaultBranchRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" + body: "*" + }; + option (google.api.method_signature) = "catalog"; + } + + // Get which branch is currently default branch set by + // [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] + // method under a specified parent catalog. + rpc GetDefaultBranch(GetDefaultBranchRequest) + returns (GetDefaultBranchResponse) { + option (google.api.http) = { + get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + }; + option (google.api.method_signature) = "catalog"; + } +} + +// Request for +// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] +// method. +message ListCatalogsRequest { + // Required. The account resource name with an associated location. + // + // If the caller does not have permission to list + // [Catalog][google.cloud.retail.v2.Catalog]s under this location, regardless + // of whether or not this location exists, a PERMISSION_DENIED error is + // returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of [Catalog][google.cloud.retail.v2.Catalog]s to return. If + // unspecified, defaults to 50. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 2; + + // A page token + // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2.ListCatalogsResponse.next_page_token], + // received from a previous + // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; +} + +// Response for +// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] +// method. +message ListCatalogsResponse { + // All the customer's [Catalog][google.cloud.retail.v2.Catalog]s. + repeated Catalog catalogs = 1; + + // A token that can be sent as + // [ListCatalogsRequest.page_token][google.cloud.retail.v2.ListCatalogsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request for +// [CatalogService.UpdateCatalog][google.cloud.retail.v2.CatalogService.UpdateCatalog] +// method. +message UpdateCatalogRequest { + // Required. The [Catalog][google.cloud.retail.v2.Catalog] to update. + // + // If the caller does not have permission to update the + // [Catalog][google.cloud.retail.v2.Catalog], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the [Catalog][google.cloud.retail.v2.Catalog] to update does not exist, + // a NOT_FOUND error is returned. + Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Catalog][google.cloud.retail.v2.Catalog] to update. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message to set a specified branch as new default_branch. +message SetDefaultBranchRequest { + // Full resource name of the catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // The final component of the resource name of a branch. + // + // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // If there are no sufficient active products in the targeted branch and + // [force][google.cloud.retail.v2.SetDefaultBranchRequest.force] is not set, a + // FAILED_PRECONDITION error is returned. + string branch_id = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Some note on this request, this can be retrieved by + // [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch] + // before next valid default branch set occurs. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string note = 3; + + // If set to true, it permits switching to a branch with + // [branch_id][google.cloud.retail.v2.SetDefaultBranchRequest.branch_id] even + // if it has no sufficient active products. + bool force = 4; +} + +// Request message to show which branch is currently the default branch. +message GetDefaultBranchRequest { + // The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response message of +// [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch]. +message GetDefaultBranchResponse { + // Full resource name of the branch id currently set as default branch. + string branch = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // The time when this branch is set to default. + google.protobuf.Timestamp set_time = 2; + + // This corresponds to + // [SetDefaultBranchRequest.note][google.cloud.retail.v2.SetDefaultBranchRequest.note] + // field, when this branch was set as default. + string note = 3; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto new file mode 100644 index 00000000..733b8cca --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto @@ -0,0 +1,479 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// An intended audience of the [Product][google.cloud.retail.v2.Product] for +// whom it's sold. +message Audience { + // The genders of the audience. Strongly encouraged to use the standard + // values: "male", "female", "unisex". + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [gender](https://support.google.com/merchants/answer/6324479). Schema.org + // property + // [Product.audience.suggestedGender](https://schema.org/suggestedGender). + repeated string genders = 1; + + // The age groups of the audience. Strongly encouraged to use the standard + // values: "newborn" (up to 3 months old), "infant" (3–12 months old), + // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically + // teens or older). + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [age_group](https://support.google.com/merchants/answer/6324463). + // Schema.org property + // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and + // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). + repeated string age_groups = 2; +} + +// The color information of a [Product][google.cloud.retail.v2.Product]. +message ColorInfo { + // The standard color families. Strongly recommended to use the following + // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", + // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and + // "Mixed". Normally it is expected to have only 1 color family. May consider + // using single "Mixed" instead of multiple values. + // + // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string color_families = 1; + + // The color display names, which may be different from standard color family + // names, such as the color aliases used in the website frontend. Normally + // it is expected to have only 1 color. May consider using single "Mixed" + // instead of multiple values. + // + // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string colors = 2; +} + +// A custom attribute that is not explicitly modeled in +// [Product][google.cloud.retail.v2.Product]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated double numbers = 2; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][] of the + // [Catalog][google.cloud.retail.v2.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. + // + // Only set if type [text][google.cloud.retail.v2.CustomAttribute.text] is + // set. Otherwise, a INVALID_ARGUMENT error is returned. + optional bool searchable = 3; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][] of the + // [Catalog][google.cloud.retail.v2.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // indexed, so that it can be filtered, faceted or boosted in + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. + // + // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter], + // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] + // for more details. + optional bool indexable = 4; +} + +// Fulfillment information, such as the store IDs for in-store pickup or region +// IDs for different shipping methods. +message FulfillmentInfo { + // The fulfillment type, including commonly used types (such as pickup in + // store and same day delivery), and custom types. Customers have to map + // custom types to their display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + string type = 1; + + // The IDs for this [type][google.cloud.retail.v2.FulfillmentInfo.type], such + // as the store IDs for + // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2.FulfillmentInfo.type] + // or the region IDs for + // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2.FulfillmentInfo.type]. + // + // A maximum of 3000 values are allowed. Each value must be a string with a + // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such + // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string place_ids = 2; +} + +// [Product][google.cloud.retail.v2.Product] image. Recommendations AI and +// Retail Search do not use product images to improve prediction and search +// results. However, product images can be returned in results, and are shown in +// prediction or search previews in the console. +message Image { + // Required. URI of the image. + // + // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Height of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 height = 2; + + // Width of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 width = 3; +} + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are set, then + // the lower bound is negative infinity. + // + // This field must be not larger than + // [max][google.cloud.retail.v2.Interval.max]. Otherwise, an INVALID_ARGUMENT + // error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are set, then + // the upper bound is positive infinity. + // + // This field must be not smaller than + // [min][google.cloud.retail.v2.Interval.min]. Otherwise, an INVALID_ARGUMENT + // error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// The price information of a [Product][google.cloud.retail.v2.Product]. +message PriceInfo { + // The price range of all + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. + message PriceRange { + // The inclusive + // [Product.pricing_info.price][google.cloud.retail.v2.PriceInfo.price] + // interval of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. + Interval price = 1; + + // The inclusive + // [Product.pricing_info.original_price][google.cloud.retail.v2.PriceInfo.original_price] + // internal of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. + Interval original_price = 2; + } + + // The 3-letter currency code defined in [ISO + // 4217](https://www.iso.org/iso-4217-currency-codes.html). + // + // If this field is an unrecognizable currency code, an INVALID_ARGUMENT + // error is returned. + // + // The [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s with the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] + // must share the same + // [currency_code][google.cloud.retail.v2.PriceInfo.currency_code]. Otherwise, + // a FAILED_PRECONDITION error is returned. + string currency_code = 1; + + // Price of the product. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). Schema.org + // property [Offer.price](https://schema.org/price). + float price = 2; + + // Price of the product without any discount. If zero, by default set to be + // the [price][google.cloud.retail.v2.PriceInfo.price]. + float original_price = 3; + + // The costs associated with the sale of a particular product. Used for gross + // profit reporting. + // + // * Profit = [price][google.cloud.retail.v2.PriceInfo.price] - + // [cost][google.cloud.retail.v2.PriceInfo.cost] + // + // Google Merchant Center property + // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). + float cost = 4; + + // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] + // starts to be effective. This can be set as a future timestamp, and the + // [price][google.cloud.retail.v2.PriceInfo.price] is only used for search + // after + // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. + // If so, the + // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be + // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] + // is used before + // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. + // + // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_effective_time = 5; + + // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] + // stops to be effective. The [price][google.cloud.retail.v2.PriceInfo.price] + // is used for search before + // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. If + // this field is set, the + // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be + // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] + // is used after + // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. + // + // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_expire_time = 6; + + // Output only. The price range of all the child + // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s grouped together on the + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]. Only populated for + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. + // Do not set this field in API requests. + PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The rating of a [Product][google.cloud.retail.v2.Product]. +message Rating { + // The total number of ratings. This value is independent of the value of + // [rating_histogram][google.cloud.retail.v2.Rating.rating_histogram]. + // + // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 rating_count = 1; + + // The average rating of the [Product][google.cloud.retail.v2.Product]. + // + // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is + // returned. + float average_rating = 2; + + // List of rating counts per rating value (index = rating - 1). The list is + // empty if there is no rating. If the list is non-empty, its size is + // always 5. Otherwise, an INVALID_ARGUMENT error is returned. + // + // For example, [41, 14, 13, 47, 303]. It means that the + // [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 + // ratings with 2 star, and so on. + repeated int32 rating_histogram = 3; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. + // + // Always use a hashed value for this ID. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string user_id = 1; + + // The end user's IP address. This field is used to extract location + // information for personalization. + // + // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 + // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This should not be set when: + // + // * setting + // [SearchRequest.user_info][google.cloud.retail.v2.SearchRequest.user_info]. + // * using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] + // is set. + string ip_address = 2; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][google.cloud.retail.v2.SearchResponse.sponsored_results]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] + // is set. + string user_agent = 3; + + // True if the request is made directly from the end user, in which case the + // [ip_address][google.cloud.retail.v2.UserInfo.ip_address] and + // [user_agent][google.cloud.retail.v2.UserInfo.user_agent] can be populated + // from the HTTP request. This flag should be set only if the API request is + // made directly from the end user such as a mobile app (and not if a gateway + // or a server is processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent]. + bool direct_user_request = 4; +} + +// The inventory information at a place (e.g. a store) identified +// by a place ID. +message LocalInventory { + // The place ID for the current set of inventory information. + string place_id = 1; + + // Product price and cost information. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 2; + + // Additional local inventory attributes, for example, store name, promotion + // tags, etc. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * At most 30 attributes are allowed. + // * The key must be a UTF-8 encoded string with a length limit of 32 + // characters. + // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, + // key0LikeThis or KEY_1_LIKE_THIS. + // * The attribute values must be of the same type (text or number). + // * Only 1 value is allowed for each attribute. + // * For text values, the length limit is 256 UTF-8 characters. + // * The attribute does not support search. The `searchable` field should be + // unset or set to false. + // * The max summed total bytes of custom attribute keys and values per + // product is 5MiB. + map attributes = 3; + + // Input only. Supported fulfillment types. Valid fulfillment type values + // include commonly used types (such as pickup in store and same day + // delivery), and custom types. Customers have to map custom types to their + // display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string fulfillment_types = 4 + [(google.api.field_behavior) = INPUT_ONLY]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto new file mode 100644 index 00000000..5e7e9a6c --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto @@ -0,0 +1,198 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/import_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Auto-completion service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service CompletionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified prefix with keyword suggestions. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }; + } + + // Bulk import of processed completion dataset. + // + // Request processing is asynchronous. Partial updating is not supported. + // + // The operation is successfully finished only after the imported suggestions + // are indexed successfully and ready for serving. The process takes hours. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc ImportCompletionData(ImportCompletionDataRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.ImportCompletionDataResponse" + metadata_type: "google.cloud.retail.v2.ImportMetadata" + }; + } +} + +// Auto-complete parameters. +message CompleteQueryRequest { + // Required. Catalog for which the completion is performed. + // + // Full resource name of catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The query used to generate suggestions. + // + // The maximum number of allowed characters is 255. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required field. A unique identifier for tracking visitors. For example, + // this could be implemented with an HTTP cookie, which should be able to + // uniquely identify a visitor on a single device. This unique identifier + // should not change if the visitor logs in or out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 7; + + // The language filters applied to the output suggestions. If set, it should + // contain the language of the query. If not set, suggestions are returned + // without considering language restrictions. This is the BCP-47 language + // code, such as "en-US" or "sr-Latn". For more information, see [Tags for + // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + // number of language codes is 3. + repeated string language_codes = 3; + + // The device type context for completion suggestions. + // It is useful to apply different suggestions on different device types, e.g. + // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + // types. + // + // Supported formats: + // + // * `UNKNOWN_DEVICE_TYPE` + // + // * `DESKTOP` + // + // * `MOBILE` + // + // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + string device_type = 4; + + // Determines which dataset to use for fetching completion. "user-data" will + // use the imported dataset through + // [CompletionService.ImportCompletionData][google.cloud.retail.v2.CompletionService.ImportCompletionData]. + // "cloud-retail" will use the dataset generated by cloud retail based on user + // events. If leave empty, it will use the "user-data". + // + // Current supported values: + // + // * user-data + // + // * cloud-retail + // This option requires additional allowlisting. Before using cloud-retail, + // contact Cloud Retail support team first. + string dataset = 6; + + // Completion max suggestions. If left unset or set to 0, then will fallback + // to the configured value [CompletionConfig.max_suggestions][]. + // + // The maximum allowed max suggestions is 20. If it is set higher, it will be + // capped by 20. + int32 max_suggestions = 5; +} + +// Response of the auto-complete query. +message CompleteQueryResponse { + // Resource that represents completion results. + message CompletionResult { + // The suggestion for the query. + string suggestion = 1; + + // Custom attributes for the suggestion term. + // * For "user-data", the attributes are additional custom attributes + // ingested through BigQuery. + // * For "cloud-retail", the attributes are product attributes generated + // by Cloud Retail. + map attributes = 2; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Results of the matching suggestions. The result list is ordered and the + // first result is top suggestion. + repeated CompletionResult completion_results = 1; + + // A unique complete token. This should be included in the + // [UserEvent.completion_detail][google.cloud.retail.v2.UserEvent.completion_detail] + // for search events resulting from this completion, which enables accurate + // attribution of complete model performance. + string attribution_token = 2; + + // Matched recent searches of this user. The maximum number of recent searches + // is 10. This field is a restricted feature. Contact Retail Search support + // team if you are interested in enabling it. + // + // This feature is only available when + // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2.CompleteQueryRequest.visitor_id] + // field is set and [UserEvent][google.cloud.retail.v2.UserEvent] is imported. + // The recent searches satisfy the follow rules: + // * They are ordered from latest to oldest. + // * They are matched with + // [CompleteQueryRequest.query][google.cloud.retail.v2.CompleteQueryRequest.query] + // case insensitively. + // * They are transformed to lower cases. + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto new file mode 100644 index 00000000..74cec22a --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto @@ -0,0 +1,394 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/cloud/retail/v2/user_event.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Google Cloud Storage location for input content. +// format. +message GcsSource { + // Required. Google Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. A request can + // contain at most 100 files, and each file can be up to 2 GB. See + // [Importing product + // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) + // for the expected file format and setup instructions. + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] + // per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2.UserEvent] per line. + // * `user_event_ga360`: Using + // https://support.google.com/analytics/answer/3437719. + // + // Supported values for control imports: + // + // * 'control' (default): One JSON [Control][] per line. + // + // Supported values for catalog attribute imports: + // + // * 'catalog_attribute' (default): One CSV [CatalogAttribute][] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + google.type.Date partition_date = 6; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 5; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 3; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] + // per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2.UserEvent] per line. + // * `user_event_ga360`: + // The schema is available here: + // https://support.google.com/analytics/answer/3437719. + // * `user_event_ga4`: This feature is in private preview. Please contact the + // support team for importing Google Analytics 4 events. + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for auto-completion imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + string data_schema = 4; +} + +// The inline source for the input config for ImportProducts method. +message ProductInlineSource { + // Required. A list of products to update/create. Each product must have a + // valid [Product.id][google.cloud.retail.v2.Product.id]. Recommended max of + // 100 items. + repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The inline source for the input config for ImportUserEvents method. +message UserEventInlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configuration of destination for Import related errors. +message ImportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors will be written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for Import methods. +message ImportProductsRequest { + // Indicates how imported products are reconciled with the existing products + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new products or updates existing products. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire product dataset. Existing + // products may be deleted if they are not present in the source location. + // + // Can only be set while using + // [BigQuerySource][google.cloud.retail.v2.BigQuerySource]. And the BigQuery + // dataset must be created in the data location "us (multiple regions in + // United States)", otherwise a PERMISSION_DENIED error is thrown. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + FULL = 2; + } + + // Required. + // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + // + // If no updateMask is specified, requires products.create permission. + // If updateMask is specified, requires products.update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Deprecated. This field has no effect. + string request_id = 6 [deprecated = true]; + + // Required. The desired input location of the data. + ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. + ImportErrorsConfig errors_config = 3; + + // Indicates which fields in the provided imported 'products' to update. If + // not set, will by default update all fields. + google.protobuf.FieldMask update_mask = 4; + + // The mode of reconciliation between existing products and the products to be + // imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 5; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + string notification_pubsub_topic = 7; +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // Required. `projects/1234/locations/global/catalogs/default_catalog` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + UserEventInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorsConfig errors_config = 3; +} + +// Request message for ImportCompletionData methods. +message ImportCompletionDataRequest { + // Required. The catalog which the suggestions dataset belongs to. + // + // Format: `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + CompletionDataInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 3; +} + +// The input config source for products. +message ProductInputConfig { + // Required. The source of the input. + oneof source { + // The Inline source for the input content for products. + ProductInlineSource product_inline_source = 1; + + // Google Cloud Storage location for the input content. + GcsSource gcs_source = 2; + + // BigQuery input source. + BigQuerySource big_query_source = 3; + } +} + +// The input config source for user events. +message UserEventInputConfig { + // The source of the input. + oneof source { + // Required. The Inline source for the input content for UserEvents. + UserEventInlineSource user_event_inline_source = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Google Cloud Storage location for the input content. + GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource big_query_source = 3 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// The input config source for completion data. +message CompletionDataInputConfig { + // The source of the input. + // + // Supported + // [BigQuerySource.data_schema][google.cloud.retail.v2.BigQuerySource.data_schema] + // values for suggestions imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + oneof source { + // Required. BigQuery input source. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + BigQuerySource big_query_source = 1 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// Metadata related to the progress of the Import operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ImportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; + + // Deprecated. This field is never set. + string request_id = 5 [deprecated = true]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; +} + +// Response of the +// [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest]. If the +// long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorsConfig errors_config = 2; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorsConfig errors_config = 2; + + // Aggregated statistics of user event import status. + UserEventImportSummary import_summary = 3; +} + +// A summary of import result. The UserEventImportSummary summarizes +// the import status for user events. +message UserEventImportSummary { + // Count of user events imported with complete existing catalog information. + int64 joined_events_count = 1; + + // Count of user events imported, but with catalog information not found + // in the imported catalog. + int64 unjoined_events_count = 2; +} + +// Response of the +// [ImportCompletionDataRequest][google.cloud.retail.v2.ImportCompletionDataRequest]. +// If the long running operation is done, this message is returned by the +// google.longrunning.Operations.response field if the operation is successful. +message ImportCompletionDataResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto new file mode 100644 index 00000000..061db142 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto @@ -0,0 +1,194 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "PredictionServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for making recommendation prediction. +service PredictionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation prediction. + rpc Predict(PredictRequest) returns (PredictResponse) { + option (google.api.http) = { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" + body: "*" + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} + // The ID of the Recommendations AI placement. Before you can request + // predictions from your model, you must create at least one placement for it. + // For more information, see [Managing + // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + // + // The full list of available placements can be seen at + // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the predict request. Note that this user event detail + // won't be ingested to userEvent logs. Thus, a separate userEvent write + // request is required for event logging. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return per page. Set this property + // to the number of prediction results needed. If zero, the service will + // choose a reasonable default. The maximum allowed value is 100. Values + // above 100 will be coerced to 100. + int32 page_size = 3; + + // The previous PredictResponse.next_page_token. + string page_token = 4; + + // Filter for restricting prediction results with a length limit of 5,000 + // characters. Accepts values for tags and the `filterOutOfStockItems` flag. + // + // * Tag expressions. Restricts predictions to products that match all of the + // specified tags. Boolean operators `OR` and `NOT` are supported if the + // expression is enclosed in parentheses, and must be separated from the + // tag values by a space. `-"tagA"` is also supported and is equivalent to + // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + // with a size limit of 1,000 characters. + // + // Note: "Recently viewed" models don't support tag filtering at the + // moment. + // + // * filterOutOfStockItems. Restricts predictions to products that do not + // have a + // stockState value of OUT_OF_STOCK. + // + // Examples: + // + // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + // * filterOutOfStockItems tag=(-"promotional") + // * filterOutOfStockItems + // + // If your filter blocks all prediction results, the API will return generic + // (unfiltered) popular products. If you only want results strictly matching + // the filters, set `strictFiltering` to True in `PredictRequest.params` to + // receive empty results instead. + // Note that the API will never return items with storageStatus of "EXPIRED" + // or "DELETED" regardless of filter choices. + string filter = 5; + + // Use validate only mode for this prediction query. If set to true, a + // dummy model will be used that returns arbitrary products. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 6; + + // Additional domain specific parameters for the predictions. + // + // Allowed values: + // + // * `returnProduct`: Boolean. If set to true, the associated product + // object will be returned in the `results.metadata` field in the + // prediction response. + // * `returnScore`: Boolean. If set to true, the prediction 'score' + // corresponding to each returned product will be set in the + // `results.metadata` field in the prediction response. The given + // 'score' indicates the probability of an product being clicked/purchased + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular products instead of empty if + // your filter blocks all prediction results. + // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-price-reranking', 'low-price-reranking', + // 'medium-price-reranking', 'high-price-reranking'}. This gives + // request-level control and adjusts prediction results based on product + // price. + // * `diversityLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-diversity', 'low-diversity', + // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + // request-level control and adjusts prediction results based on product + // category. + map params = 7; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters, and cannot be empty. Values can be empty, and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 8; +} + +// Response message for predict method. +message PredictResponse { + // PredictionResult represents the recommendation prediction results. + message PredictionResult { + // ID of the recommended product + string id = 1; + + // Additional product metadata / annotations. + // + // Possible values: + // + // * `product`: JSON representation of the product. Will be set if + // `returnProduct` is set to true in `PredictRequest.params`. + // * `score`: Prediction score in double value. Will be set if + // `returnScore` is set to true in `PredictRequest.params`. + map metadata = 2; + } + + // A list of recommended products. The order represents the ranking (from the + // most relevant product to the least). + repeated PredictionResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this + // recommendation, which enables accurate attribution of recommendation model + // performance. + string attribution_token = 2; + + // IDs of products in the request that were missing from the inventory. + repeated string missing_ids = 3; + + // True if the validateOnly property was set in the request. + bool validate_only = 4; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto new file mode 100644 index 00000000..ea861fb6 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto @@ -0,0 +1,558 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/promotion.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" +}; + +// Product captures all metadata information of items to be recommended or +// searched. +message Product { + option (google.api.resource) = { + type: "retail.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }; + + // The type of this product. + enum Type { + // Default value. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] + // if unset. + TYPE_UNSPECIFIED = 0; + + // The primary type. + // + // As the primary unit for predicting, indexing and search serving, a + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] is grouped with multiple + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. + PRIMARY = 1; + + // The variant type. + // + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s usually share some common + // attributes on the same + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s, but they have variant + // attributes like different colors, sizes and prices, etc. + VARIANT = 2; + + // The collection type. Collection products are bundled + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s or + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s that are sold together, such + // as a jewelry set with necklaces, earrings and rings, etc. + COLLECTION = 3; + } + + // Product availability. If this field is unspecified, the product is + // assumed to be in stock. + enum Availability { + // Default product availability. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK] + // if unset. + AVAILABILITY_UNSPECIFIED = 0; + + // Product in stock. + IN_STOCK = 1; + + // Product out of stock. + OUT_OF_STOCK = 2; + + // Product that is in pre-order state. + PREORDER = 3; + + // Product that is back-ordered (i.e. temporarily out of stock). + BACKORDER = 4; + } + + oneof expiration { + // The timestamp when this product becomes unavailable for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // If it is set, the [Product][google.cloud.retail.v2.Product] is not + // available for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after + // [expire_time][google.cloud.retail.v2.Product.expire_time]. However, the + // product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // [expire_time][google.cloud.retail.v2.Product.expire_time] must be later + // than [available_time][google.cloud.retail.v2.Product.available_time] and + // [publish_time][google.cloud.retail.v2.Product.publish_time], otherwise an + // INVALID_ARGUMENT error is thrown. + // + // Corresponding properties: Google Merchant Center property + // [expiration_date](https://support.google.com/merchants/answer/6324499). + google.protobuf.Timestamp expire_time = 16; + + // Input only. The TTL (time to live) of the product. + // + // If it is set, it must be a non-negative value, and + // [expire_time][google.cloud.retail.v2.Product.expire_time] is set as + // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. The + // derived [expire_time][google.cloud.retail.v2.Product.expire_time] is + // returned in the output and [ttl][google.cloud.retail.v2.Product.ttl] is + // left blank when retrieving the [Product][google.cloud.retail.v2.Product]. + // + // If it is set, the product is not available for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after + // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. + // However, the product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + google.protobuf.Duration ttl = 17 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Immutable. Full resource name of the product, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. [Product][google.cloud.retail.v2.Product] identifier, which is + // the final component of [name][google.cloud.retail.v2.Product.name]. For + // example, this field is "id_1", if + // [name][google.cloud.retail.v2.Product.name] is + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [id](https://support.google.com/merchants/answer/6324405). Schema.org + // property [Product.sku](https://schema.org/sku). + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The type of the product. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] + // if unset. + Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Variant group identifier. Must be an + // [id][google.cloud.retail.v2.Product.id], with the same parent branch with + // this product. Otherwise, an error is thrown. + // + // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s, this field can only be empty or + // set to the same value as [id][google.cloud.retail.v2.Product.id]. + // + // For VARIANT [Product][google.cloud.retail.v2.Product]s, this field cannot + // be empty. A maximum of 2,000 products are allowed to share the same + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]. Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // Corresponding properties: Google Merchant Center property + // [item_group_id](https://support.google.com/merchants/answer/6324507). + // Schema.org property + // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). + string primary_product_id = 4; + + // The [id][google.cloud.retail.v2.Product.id] of the collection members when + // [type][google.cloud.retail.v2.Product.type] is + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]. + // + // Non-existent product ids are allowed. + // The [type][google.cloud.retail.v2.Product.type] of the members must be + // either [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] or + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] otherwise and + // INVALID_ARGUMENT error is thrown. Should not set it for other types. A + // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is + // return. + repeated string collection_member_ids = 5; + + // The Global Trade Item Number (GTIN) of the product. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Corresponding properties: Google Merchant Center property + // [gtin](https://support.google.com/merchants/answer/6324461). + // Schema.org property + // [Product.isbn](https://schema.org/isbn), + // [Product.gtin8](https://schema.org/gtin8), + // [Product.gtin12](https://schema.org/gtin12), + // [Product.gtin13](https://schema.org/gtin13), or + // [Product.gtin14](https://schema.org/gtin14). + // + // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. + string gtin = 6; + + // Product categories. This field is repeated for supporting one product + // belonging to several parallel categories. Strongly recommended using the + // full path for better search / recommendation quality. + // + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // For example, if a shoes product belongs to both + // ["Shoes & Accessories" -> "Shoes"] and + // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be + // represented as: + // + // "categories": [ + // "Shoes & Accessories > Shoes", + // "Sports & Fitness > Athletic Clothing > Shoes" + // ] + // + // Must be set for [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] otherwise an INVALID_ARGUMENT + // error is returned. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2.Product]. Empty values are not allowed. + // Each value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [google_product_category][mc_google_product_category]. Schema.org property + // [Product.category] (https://schema.org/category). + // + // [mc_google_product_category]: + // https://support.google.com/merchants/answer/6324436 + repeated string categories = 7; + + // Required. Product title. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [title](https://support.google.com/merchants/answer/6324415). Schema.org + // property [Product.name](https://schema.org/name). + string title = 8 [(google.api.field_behavior) = REQUIRED]; + + // The brands of the product. + // + // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded + // string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [brand](https://support.google.com/merchants/answer/6324351). Schema.org + // property [Product.brand](https://schema.org/brand). + repeated string brands = 9; + + // Product description. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [description](https://support.google.com/merchants/answer/6324468). + // Schema.org property [Product.description](https://schema.org/description). + string description = 10; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // + // For product prediction, this field is ignored and the model automatically + // detects the text language. The [Product][google.cloud.retail.v2.Product] + // can include text in different languages, but duplicating + // [Product][google.cloud.retail.v2.Product]s to provide text in multiple + // languages can result in degraded model performance. + // + // For product search this field is in use. It defaults to "en-US" if unset. + string language_code = 11; + + // Highly encouraged. Extra product attributes to be included. For example, + // for products, this could include the store name, vendor, style, color, etc. + // These are very strong signals for recommendation model, thus we highly + // recommend providing the attributes here. + // + // Features that can take on one of a limited number of possible values. Two + // types of features can be set are: + // + // Textual features. some examples would be the brand/maker of a product, or + // country of a customer. Numerical features. Some examples would be the + // height/weight of a product, or age of a customer. + // + // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, + // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} + // }`. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * Max entries count: 200. + // * The key must be a UTF-8 encoded string with a length limit of 128 + // characters. + // * For indexable attribute, the key must match the pattern: + // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or + // `KEY_1_LIKE_THIS`. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a non-empty UTF-8 encoded string with a + // length limit of 256 characters. + // * For number attributes, at most 400 values are allowed. + map attributes = 12; + + // Custom tags associated with the product. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2.Product]. This value must be a UTF-8 + // encoded string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This tag can be used for filtering recommendation results by passing the + // tag as part of the + // [PredictRequest.filter][google.cloud.retail.v2.PredictRequest.filter]. + // + // Corresponding properties: Google Merchant Center property + // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). + repeated string tags = 13; + + // Product price and cost information. + // + // Corresponding properties: Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 14; + + // The rating of this product. + Rating rating = 15; + + // The timestamp when this [Product][google.cloud.retail.v2.Product] becomes + // available for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + google.protobuf.Timestamp available_time = 18; + + // The online availability of the [Product][google.cloud.retail.v2.Product]. + // Default to + // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK]. + // + // Corresponding properties: Google Merchant Center property + // [availability](https://support.google.com/merchants/answer/6324448). + // Schema.org property [Offer.availability](https://schema.org/availability). + Availability availability = 19; + + // The available quantity of the item. + google.protobuf.Int32Value available_quantity = 20; + + // Fulfillment information, such as the store IDs for in-store pickup or + // region IDs for different shipping methods. + // + // All the elements must have distinct + // [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type]. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated FulfillmentInfo fulfillment_info = 21; + + // Canonical URL directly linking to the product detail page. + // + // It is strongly recommended to provide a valid uri for the product, + // otherwise the service performance could be significantly degraded. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [link](https://support.google.com/merchants/answer/6324416). Schema.org + // property [Offer.url](https://schema.org/url). + string uri = 22; + + // Product images for the product. We highly recommend putting the main + // image first. + // + // A maximum of 300 images are allowed. + // + // Corresponding properties: Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + repeated Image images = 23; + + // The target group associated with a given audience (e.g. male, veterans, + // car owners, musicians, etc.) of the product. + Audience audience = 24; + + // The color of the product. + // + // Corresponding properties: Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + ColorInfo color_info = 25; + + // The size of the product. To represent different size systems or size types, + // consider using this format: [[[size_system:]size_type:]size_value]. + // + // For example, in "US:MENS:M", "US" represents size system; "MENS" represents + // size type; "M" represents size value. In "GIRLS:27", size system is empty; + // "GIRLS" represents size type; "27" represents size value. In "32 inches", + // both size system and size type are empty, while size value is "32 inches". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [size](https://support.google.com/merchants/answer/6324492), + // [size_type](https://support.google.com/merchants/answer/6324497), and + // [size_system](https://support.google.com/merchants/answer/6324502). + // Schema.org property [Product.size](https://schema.org/size). + repeated string sizes = 26; + + // The material of the product. For example, "leather", "wooden". + // + // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 200 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [material](https://support.google.com/merchants/answer/6324410). Schema.org + // property [Product.material](https://schema.org/material). + repeated string materials = 27; + + // The pattern or graphic print of the product. For example, "striped", "polka + // dot", "paisley". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org + // property [Product.pattern](https://schema.org/pattern). + repeated string patterns = 28; + + // The condition of the product. Strongly encouraged to use the standard + // values: "new", "refurbished", "used". + // + // A maximum of 1 value is allowed per + // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [condition](https://support.google.com/merchants/answer/6324469). + // Schema.org property + // [Offer.itemCondition](https://schema.org/itemCondition). + repeated string conditions = 29; + + // The promotions applied to the product. A maximum of 10 values are allowed + // per [Product][google.cloud.retail.v2.Product]. Only + // [Promotion.promotion_id][google.cloud.retail.v2.Promotion.promotion_id] + // will be used, other fields will be ignored if set. + repeated Promotion promotions = 34; + + // The timestamp when the product is published by the retailer for the first + // time, which indicates the freshness of the products. Note that this field + // is different from + // [available_time][google.cloud.retail.v2.Product.available_time], given it + // purely describes product freshness regardless of when it is available on + // search and recommendation. + google.protobuf.Timestamp publish_time = 33; + + // Indicates which fields in the [Product][google.cloud.retail.v2.Product]s + // are returned in [SearchResponse][google.cloud.retail.v2.SearchResponse]. + // + // Supported fields for all [type][google.cloud.retail.v2.Product.type]s: + // + // * [audience][google.cloud.retail.v2.Product.audience] + // * [availability][google.cloud.retail.v2.Product.availability] + // * [brands][google.cloud.retail.v2.Product.brands] + // * [color_info][google.cloud.retail.v2.Product.color_info] + // * [conditions][google.cloud.retail.v2.Product.conditions] + // * [gtin][google.cloud.retail.v2.Product.gtin] + // * [materials][google.cloud.retail.v2.Product.materials] + // * [name][google.cloud.retail.v2.Product.name] + // * [patterns][google.cloud.retail.v2.Product.patterns] + // * [price_info][google.cloud.retail.v2.Product.price_info] + // * [rating][google.cloud.retail.v2.Product.rating] + // * [sizes][google.cloud.retail.v2.Product.sizes] + // * [title][google.cloud.retail.v2.Product.title] + // * [uri][google.cloud.retail.v2.Product.uri] + // + // Supported fields only for + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]: + // + // * [categories][google.cloud.retail.v2.Product.categories] + // * [description][google.cloud.retail.v2.Product.description] + // * [images][google.cloud.retail.v2.Product.images] + // + // Supported fields only for + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]: + // + // * Only the first image in [images][google.cloud.retail.v2.Product.images] + // + // To mark [attributes][google.cloud.retail.v2.Product.attributes] as + // retrievable, include paths of the form "attributes.key" where "key" is the + // key of a custom attribute, as specified in + // [attributes][google.cloud.retail.v2.Product.attributes]. + // + // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], the + // following fields are always returned in + // [SearchResponse][google.cloud.retail.v2.SearchResponse] by default: + // + // * [name][google.cloud.retail.v2.Product.name] + // + // For [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT], the + // following fields are always returned in by default: + // + // * [name][google.cloud.retail.v2.Product.name] + // * [color_info][google.cloud.retail.v2.Product.color_info] + // + // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2.SearchResponse] may increase + // response payload size and serving latency. + google.protobuf.FieldMask retrievable_fields = 30; + + // Output only. Product variants grouped together on primary product which + // share similar product attributes. It's automatically grouped by + // [primary_product_id][google.cloud.retail.v2.Product.primary_product_id] for + // all the product variants. Only populated for + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. + // Do not set this field in API requests. + repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto new file mode 100644 index 00000000..71319834 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto @@ -0,0 +1,822 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/import_config.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for ingesting [Product][google.cloud.retail.v2.Product] information +// of the customer's website. +service ProductService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Product][google.cloud.retail.v2.Product]. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Gets a [Product][google.cloud.retail.v2.Product]. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Product][google.cloud.retail.v2.Product]s. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a [Product][google.cloud.retail.v2.Product]. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v2/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Deletes a [Product][google.cloud.retail.v2.Product]. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. + // + // Request processing may be synchronous. No partial updating is supported. + // Non-existing items are created. + // + // Note that it is possible for a subset of the + // [Product][google.cloud.retail.v2.Product]s to be successfully updated. + rpc ImportProducts(ImportProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.ImportProductsResponse" + metadata_type: "google.cloud.retail.v2.ImportMetadata" + }; + } + + // Updates inventory information for a + // [Product][google.cloud.retail.v2.Product] while respecting the last update + // timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, updates are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // When inventory is updated with + // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and + // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the + // specified inventory field value(s) will overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update time for the specified inventory fields will be overwritten to the + // time of the + // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or + // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + // request. + // + // If no inventory fields are set in + // [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], + // then any pre-existing inventory information for this product will be used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], + // then any existing inventory information will be preserved. + // + // Pre-existing inventory information can only be updated with + // [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], + // [AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], + // and + // [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" + body: "*" + }; + option (google.api.method_signature) = "inventory,set_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.SetInventoryResponse" + metadata_type: "google.cloud.retail.v2.SetInventoryMetadata" + }; + } + + // Incrementally adds place IDs to + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the added place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.AddFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2.AddFulfillmentPlacesMetadata" + }; + } + + // Incrementally removes place IDs from a + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the removed place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata" + }; + } + + // Updates local inventory information for a + // [Product][google.cloud.retail.v2.Product] at a list of places, while + // respecting the last update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // inventory information. If the request is valid, the update will be enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and + // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no + // effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddLocalInventories(AddLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.AddLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2.AddLocalInventoriesMetadata" + }; + } + + // Remove local inventory information for a + // [Product][google.cloud.retail.v2.Product] at a list of places at a removal + // timestamp. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, removals are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and + // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no + // effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.RemoveLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2.RemoveLocalInventoriesMetadata" + }; + } +} + +// Request message for [CreateProduct][] method. +message CreateProductRequest { + // Required. The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The [Product][google.cloud.retail.v2.Product] to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the [Product][google.cloud.retail.v2.Product], + // which will become the final component of the + // [Product.name][google.cloud.retail.v2.Product.name]. + // + // If the caller does not have permission to create the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // This field must be unique among all + // [Product][google.cloud.retail.v2.Product]s with the same + // [parent][google.cloud.retail.v2.CreateProductRequest.parent]. Otherwise, an + // ALREADY_EXISTS error is returned. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string product_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [GetProduct][] method. +message GetProductRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the requested [Product][google.cloud.retail.v2.Product] does not exist, + // a NOT_FOUND error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for [UpdateProduct][] method. +message UpdateProductRequest { + // Required. The product to update/create. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2.Product] to update does not exist + // and + // [allow_missing][google.cloud.retail.v2.UpdateProductRequest.allow_missing] + // is not set, a NOT_FOUND error is returned. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Product][google.cloud.retail.v2.Product] to update. The immutable and + // output only fields are NOT supported. If not set, all supported fields (the + // fields that are neither immutable nor output only) are updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, a new [Product][google.cloud.retail.v2.Product] will be created. In + // this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for [DeleteProduct][] method. +message DeleteProductRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to delete the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2.Product] to delete does not exist, + // a NOT_FOUND error is returned. + // + // The [Product][google.cloud.retail.v2.Product] to delete can neither be a + // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2.Product] member nor a + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] with more than one + // [variants][google.cloud.retail.v2.Product.Type.VARIANT]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // All inventory information for the named + // [Product][google.cloud.retail.v2.Product] will be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] +// method. +message ListProductsRequest { + // Required. The parent branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use + // `default_branch` as the branch ID, to list products under the default + // branch. + // + // If the caller does not have permission to list + // [Product][google.cloud.retail.v2.Product]s under this branch, regardless of + // whether or not this branch exists, a PERMISSION_DENIED error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If + // unspecified, defaults to 100. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT error is returned. + int32 page_size = 2; + + // A page token + // [ListProductsResponse.next_page_token][google.cloud.retail.v2.ListProductsResponse.next_page_token], + // received from a previous + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; + + // A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2.ListProductsRequest.filter] is unset. + // * List [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s sharing the same + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]. For example: + // `primary_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2.Product]s bundled in a + // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2.Product]. + // For example: + // `collection_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2.Product]s with a partibular type. + // For example: + // `type = "PRIMARY"` + // `type = "VARIANT"` + // `type = "COLLECTION"` + // + // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + // + // If the specified + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] or + // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2.Product] does not exist, a NOT_FOUND error + // is returned. + string filter = 4; + + // The fields of [Product][google.cloud.retail.v2.Product] to return in the + // responses. If not set or empty, the following fields are returned: + // + // * [Product.name][google.cloud.retail.v2.Product.name] + // * [Product.id][google.cloud.retail.v2.Product.id] + // * [Product.title][google.cloud.retail.v2.Product.title] + // * [Product.uri][google.cloud.retail.v2.Product.uri] + // * [Product.images][google.cloud.retail.v2.Product.images] + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // * [Product.brands][google.cloud.retail.v2.Product.brands] + // + // If "*" is provided, all fields are returned. + // [Product.name][google.cloud.retail.v2.Product.name] is always returned no + // matter what mask is set. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask read_mask = 5; +} + +// Response message for +// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] +// method. +message ListProductsResponse { + // The [Product][google.cloud.retail.v2.Product]s. + repeated Product products = 1; + + // A token that can be sent as + // [ListProductsRequest.page_token][google.cloud.retail.v2.ListProductsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for [SetInventory][] method. +message SetInventoryRequest { + // Required. The inventory information to update. The allowable fields to + // update are: + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // * [Product.availability][google.cloud.retail.v2.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] + // The updated inventory fields must be specified in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask]. + // + // If [SetInventoryRequest.inventory.name][] is empty or invalid, an + // INVALID_ARGUMENT error is returned. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2.Product] named in + // [Product.name][google.cloud.retail.v2.Product.name], regardless of whether + // or not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2.Product] to update does not have + // existing inventory information, the provided inventory information will be + // inserted. + // + // If the [Product][google.cloud.retail.v2.Product] to update has existing + // inventory information, the provided inventory information will be merged + // while respecting the last update time for each inventory field, using the + // provided or default value for + // [SetInventoryRequest.set_time][google.cloud.retail.v2.SetInventoryRequest.set_time]. + // + // The caller can replace place IDs for a subset of fulfillment types in the + // following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types and corresponding place IDs + // to update in [SetInventoryRequest.inventory.fulfillment_info][] + // + // The caller can clear all place IDs from a subset of fulfillment types in + // the following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types to clear in + // [SetInventoryRequest.inventory.fulfillment_info][] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] + // + // The last update time is recorded for the following inventory fields: + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // * [Product.availability][google.cloud.retail.v2.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] + // + // If a full overwrite of inventory information while ignoring timestamps is + // needed, [UpdateProduct][] should be invoked instead. + Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided + // [Product][google.cloud.retail.v2.Product] to update. + // + // At least one field must be provided. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask set_mask = 2; + + // The time when the request is issued, used to prevent + // out-of-order updates on inventory fields with the last update time + // recorded. If not provided, the internal system time will be used. + google.protobuf.Timestamp set_time = 3; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] with name + // [Product.name][google.cloud.retail.v2.Product.name] is not found, the + // inventory update will still be processed and retained for at most 1 day + // until the [Product][google.cloud.retail.v2.Product] is created. If set to + // false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 4; +} + +// Metadata related to the progress of the SetInventory operation. +// Currently empty because there is no meaningful metadata populated from the +// [SetInventory][] method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the [SetInventory][] +// method. +message SetInventoryResponse {} + +// Request message for [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type], such as + // the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery" to be added for this + // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type]. Duplicate + // IDs will be automatically ignored. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // If the total number of place IDs exceeds 2000 for this + // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type] after + // adding, then the update will be rejected. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the fulfillment information will still be processed and retained for + // at most 1 day and processed once the + // [Product][google.cloud.retail.v2.Product] is created. If set to false, a + // NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the AddFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesMetadata {} + +// Response of the AddFulfillmentPlacesRequest. Currently empty because +// there is no meaningful response populated from the [AddFulfillmentPlaces][] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for [AddLocalInventories][] method. +message AddLocalInventoriesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of inventory information at difference places. Each place + // is identified by its place ID. At most 3000 inventories are allowed per + // request. + repeated LocalInventory local_inventories = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided list of + // [LocalInventory][google.cloud.retail.v2.LocalInventory] to update. The + // field is updated to the provided value. + // + // If a field is set while the place does not have a previous local inventory, + // the local inventory at that store is created. + // + // If a field is set while the value of that field is not provided, the + // original field value, if it exists, is deleted. + // + // If the mask is not set or set with empty paths, all inventory fields will + // be updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask add_mask = 4; + + // The time when the inventory updates are issued. Used to prevent + // out-of-order updates on local inventory fields. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the local inventory will still be processed and retained for at most + // 1 day and processed once the [Product][google.cloud.retail.v2.Product] is + // created. If set to false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 6; +} + +// Metadata related to the progress of the AddLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddLocalInventories][] method. +message AddLocalInventoriesMetadata {} + +// Response of the [AddLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [AddLocalInventories][] +// method. +message AddLocalInventoriesResponse {} + +// Request message for [RemoveLocalInventories][] method. +message RemoveLocalInventoriesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of place IDs to have their inventory deleted. + // At most 3000 place IDs are allowed per request. + repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; + + // The time when the inventory deletions are issued. Used to prevent + // out-of-order updates and deletions on local inventory fields. If not + // provided, the internal system time will be used. + google.protobuf.Timestamp remove_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the local inventory removal request will still be processed and + // retained for at most 1 day and processed once the + // [Product][google.cloud.retail.v2.Product] is created. If set to false, a + // NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 3; +} + +// Metadata related to the progress of the RemoveLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveLocalInventories][] method. +message RemoveLocalInventoriesMetadata {} + +// Response of the [RemoveLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [RemoveLocalInventories][] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type], such as + // the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery", to be removed for this + // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type]. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp remove_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the fulfillment information will still be processed and retained for + // at most 1 day and processed once the + // [Product][google.cloud.retail.v2.Product] is created. If set to false, a + // NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the RemoveFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the [RemoveFulfillmentPlaces][] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto new file mode 100644 index 00000000..9ba32347 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto @@ -0,0 +1,40 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "PromotionProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Promotion information. +message Promotion { + // ID of the promotion. For example, "free gift". + // + // The value must be a UTF-8 encoded string with a length limit of 128 + // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, + // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Google Merchant Center property + // [promotion](https://support.google.com/merchants/answer/7050148). + string promotion_id = 1; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto new file mode 100644 index 00000000..6c8d54c7 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto @@ -0,0 +1,79 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Metadata related to the progress of the Purge operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeMetadata {} + +// Request message for PurgeUserEvents method. +message PurgeUserEventsRequest { + // Required. The resource name of the catalog under which the events are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The filter string to specify the events to be deleted with a + // length limit of 5,000 characters. Empty string filter is not allowed. The + // eligible fields for filtering are: + // + // * `eventType`: Double quoted + // [UserEvent.event_type][google.cloud.retail.v2.UserEvent.event_type] string. + // * `eventTime`: in ISO 8601 "zulu" format. + // * `visitorId`: Double quoted string. Specifying this will delete all + // events associated with a visitor. + // * `userId`: Double quoted string. Specifying this will delete all events + // associated with a user. + // + // Examples: + // + // * Deleting all events in a time range: + // `eventTime > "2012-04-23T18:25:43.511Z" + // eventTime < "2012-04-23T18:30:43.511Z"` + // * Deleting specific eventType in time range: + // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + // * Deleting all events for a specific visitor: + // `visitorId = "visitor1024"` + // + // The filtering fields are assumed to have an implicit AND. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any user events. + bool force = 3; +} + +// Response of the PurgeUserEventsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeUserEventsResponse { + // The total count of events purged as a result of the operation. + int64 purged_events_count = 1; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto new file mode 100644 index 00000000..ec8750ae --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto @@ -0,0 +1,786 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service SearchService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" + body: "*" + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Product][google.cloud.retail.v2.Product] object, over which the facet + // values are computed. Facet key is case-sensitive. + // + // Allowed facet keys when + // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] + // is not specified: + // + // * textual_field = + // * "brands" + // * "categories" + // * "genders" + // * "ageGroups" + // * "availability" + // * "colorFamilies" + // * "colors" + // * "sizes" + // * "materials" + // * "patterns" + // * "conditions" + // * "attributes.key" + // * "pickupInStore" + // * "shipToStore" + // * "sameDayDelivery" + // * "nextDayDelivery" + // * "customFulfillment1" + // * "customFulfillment2" + // * "customFulfillment3" + // * "customFulfillment4" + // * "customFulfillment5" + // * "inventory(place_id,attributes.key)" + // + // * numerical_field = + // * "price" + // * "discount" + // * "rating" + // * "ratingCount" + // * "attributes.key" + // * "inventory(place_id,price)" + // * "inventory(place_id,original_price)" + // * "inventory(place_id,attributes.key)" + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. For example, when using + // "pickupInStore" as key and set restricted values to + // ["store123", "store456"], only facets for "store123" and "store456" are + // returned. Only supported on textual fields and fulfillments. + // Maximum is 20. + // + // Must be set for the fulfillment facet keys: + // + // * pickupInStore + // + // * shipToStore + // + // * sameDayDelivery + // + // * nextDayDelivery + // + // * customFulfillment1 + // + // * customFulfillment2 + // + // * customFulfillment3 + // + // * customFulfillment4 + // + // * customFulfillment5 + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the + // "categories" facet will give only "Women > Shoe" and "Women > Dress". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 8; + + // Only get facet values that contains the given strings. For example, + // suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the + // "categories" facet will give only "Women > Shoe" and "Men > Shoe". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 9; + + // The order in which [Facet.values][] are returned. + // + // Allowed values are: + // + // * "count desc", which means order by [Facet.FacetValue.count][] + // descending. + // + // * "value desc", which means order by [Facet.FacetValue.value][] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.intervals]; + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // are sorted in the order given by + // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.restricted_values]. + string order_by = 4; + + // The query that is used to compute facet for the given facet key. + // When provided, it will override the default behavior of facet + // computation. The query syntax is the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // detail syntax and limitations. Notice that there is no limitation on + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // when query is specified. + // + // In the response, [FacetValue.value][] will be always "1" and + // [FacetValue.count][] will be the number of results that matches the + // query. + // + // For example, you can set a customized facet for "shipToStore", + // where + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // is "customizedShipToStore", and + // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] + // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". + // Then the facet will count the products that are both in stock and ship + // to store "123". + string query = 5; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // By default, + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // For example, suppose there are 100 products with color facet "Red" and + // 200 products with color facet "Blue". A query containing the filter + // "colorFamilies:ANY("Red")" and have "colorFamilies" as + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // will by default return the "Red" with count 100. + // + // If this field contains "colorFamilies", then the query returns both the + // "Red" with count 100 and "Blue" with count 200, because the + // "colorFamilies" key is now excluded from the filter. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined by Google + // Retail Search. It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined by + // Google Retail Search. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how Google Retail Search orders "gender" and + // "rating" facets. However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // The specifications of dynamically generated facets. + message DynamicFacetSpec { + // Enum to control DynamicFacet mode + enum Mode { + // Default value. + MODE_UNSPECIFIED = 0; + + // Disable Dynamic Facet. + DISABLED = 1; + + // Automatic mode built by Google Retail Search. + ENABLED = 2; + } + + // Mode of the DynamicFacet feature. + // Defaults to + // [Mode.DISABLED][google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode.DISABLED] + // if it's unset. + Mode mode = 1; + } + + // Boost specification to boost certain items. + message BoostSpec { + // Boost applies to products which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue": + // * (id: ANY("product_1", "product_2")) AND (colorFamilies: + // ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a product matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 10. + repeated ConditionBoostSpec condition_boost_specs = 1; + + // Whether to skip boostspec validation. If this field is set to true, + // invalid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] + // will be ignored and valid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] + // will still be applied. + optional bool skip_boost_spec_validation = 2; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. This defaults to + // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.retail.v2.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by Google Retail Search. + AUTO = 3; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + + // Whether to pin unexpanded results. If this field is set to true, + // unexpanded products are always at the top of the search results, followed + // by the expanded results. + bool pin_unexpanded_results = 2; + } + + // The specification for personalization. + message PersonalizationSpec { + // The personalization mode of each search request. + enum Mode { + // Default value. Defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The search mode of each search request. + enum SearchMode { + // Default value. In this case both product search and faceted search will + // be performed. Both [SearchResponse.SearchResult] and + // [SearchResponse.Facet] will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only [SearchResponse.SearchResult] will be returned. + // [SearchResponse.Facet] will not be returned, even if + // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] + // or + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] + // is set. + PRODUCT_SEARCH_ONLY = 1; + + // Only faceted search will be performed. The product search will be + // disabled. + // + // When in this mode, one or both of [SearchRequest.facet_spec][] and + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] + // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only + // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the search engine placement, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` + // This field is used to identify the serving configuration name and the set + // of models that will be used to make the search. + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. + // + // Use "default_branch" as the branch ID or leave this field empty, to search + // products under the default branch. + string branch = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Raw search query. + string query = 3; + + // Required. A unique identifier for tracking visitors. For example, this + // could be implemented with an HTTP cookie, which should be able to uniquely + // identify a visitor on a single device. This unique identifier should not + // change if the visitor logs in or out of the website. + // + // This should be the same identifier as + // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; + + // User information. + UserInfo user_info = 5; + + // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If + // unspecified, defaults to a reasonable value. The maximum allowed value is + // 120. Values above 120 will be coerced to 120. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 7; + + // A page token + // [SearchResponse.next_page_token][google.cloud.retail.v2.SearchResponse.next_page_token], + // received from a previous + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] must + // match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + // error is returned. + string page_token = 8; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the [Product][google.cloud.retail.v2.Product]s + // deemed by the API as relevant) in search results. This field is only + // considered if [page_token][google.cloud.retail.v2.SearchRequest.page_token] + // is unset. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 offset = 9; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. Filter + // expression is case-sensitive. See more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string filter = 10; + + // The default filter that is applied when a user performs a search without + // checking any filters on the search page. + // + // The filter applied to every search request when quality improvement such as + // query expansion is needed. For example, if a query does not have enough + // results, an expanded query with + // [SearchRequest.canonical_filter][google.cloud.retail.v2.SearchRequest.canonical_filter] + // will be returned as a supplement of the original query. This field is + // strongly recommended to achieve high search quality. + // + // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // more details about filter syntax. + string canonical_filter = 28; + + // The order in which products are returned. Products can be ordered by + // a field in an [Product][google.cloud.retail.v2.Product] object. Leave it + // unset if ordered by relevance. OrderBy expression is case-sensitive. See + // more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#order). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string order_by = 11; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated FacetSpec facet_specs = 12; + + // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + // to enable dynamic facets. Do not set this field. + // + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; + + // Boost specification to boost certain products. See more details at this + // [user guide](https://cloud.google.com/retail/docs/boosting). + // + // Notice that if both [ServingConfig.boost_control_ids][] and + // [SearchRequest.boost_spec] are set, the boost conditions from both places + // are evaluated. If a search request matches multiple boost conditions, + // the final boost score is equal to the sum of the boost scores from all + // matched boost conditions. + BoostSpec boost_spec = 13; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + QueryExpansionSpec query_expansion_spec = 14; + + // The keys to fetch and rollup the matching + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s attributes, + // [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo] or + // [LocalInventory][google.cloud.retail.v2.LocalInventory]s attributes. The + // attributes from all the matching + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s or + // [LocalInventory][google.cloud.retail.v2.LocalInventory]s are merged and + // de-duplicated. Notice that rollup attributes will lead to extra query + // latency. Maximum number of keys is 30. + // + // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], a + // fulfillment type and a fulfillment ID must be provided in the format of + // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + // "pickupInStore" is fulfillment type and "store123" is the store ID. + // + // Supported keys are: + // + // * colorFamilies + // * price + // * originalPrice + // * discount + // * variantId + // * inventory(place_id,price) + // * inventory(place_id,original_price) + // * inventory(place_id,attributes.key), where key is any key in the + // [Product.inventories.attributes][] map. + // * attributes.key, where key is any key in the + // [Product.attributes][google.cloud.retail.v2.Product.attributes] map. + // * pickupInStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "pickup-in-store". + // * shipToStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "ship-to-store". + // * sameDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "same-day-delivery". + // * nextDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "next-day-delivery". + // * customFulfillment1.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-1". + // * customFulfillment2.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-2". + // * customFulfillment3.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-3". + // * customFulfillment4.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-4". + // * customFulfillment5.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-5". + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + repeated string variant_rollup_keys = 17; + + // The categories associated with a category page. Required for category + // navigation queries to achieve good search quality. The format should be + // the same as + // [UserEvent.page_categories][google.cloud.retail.v2.UserEvent.page_categories]; + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + repeated string page_categories = 23; + + // The search mode of the search request. If not specified, a single search + // request triggers both product search and faceted search. + SearchMode search_mode = 31; + + // The specification for personalization. + PersonalizationSpec personalization_spec = 32; +} + +// Response message for +// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Product.id][google.cloud.retail.v2.Product.id] of the searched + // [Product][google.cloud.retail.v2.Product]. + string id = 1; + + // The product data snippet in the search response. Only + // [Product.name][google.cloud.retail.v2.Product.name] is guaranteed to be + // populated. + // + // [Product.variants][google.cloud.retail.v2.Product.variants] contains the + // product variants that match the search query. If there are multiple + // product variants matching the query, top 5 most relevant product variants + // are returned and ordered by relevancy. + // + // If relevancy can be deternmined, use + // [matching_variant_fields][google.cloud.retail.v2.SearchResponse.SearchResult.matching_variant_fields] + // to look up matched product variants fields. If relevancy cannot be + // determined, e.g. when searching "shoe" all products in a shoe product can + // be a match, 5 product variants are returned but order is meaningless. + Product product = 2; + + // The count of matched + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. + int32 matching_variant_count = 3; + + // If a [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] matches the search query, this + // map indicates which [Product][google.cloud.retail.v2.Product] fields are + // matched. The key is the + // [Product.name][google.cloud.retail.v2.Product.name], the value is a field + // mask of the matched [Product][google.cloud.retail.v2.Product] fields. If + // matched attributes cannot be determined, this map will be empty. + // + // For example, a key "sku1" with field mask + // "products.color_info" indicates there is a match between + // "sku1" [ColorInfo][google.cloud.retail.v2.ColorInfo] and the query. + map matching_variant_fields = 4; + + // The rollup matching + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] attributes. The key is one of + // the + // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2.SearchRequest.variant_rollup_keys]. + // The values are the merged and de-duplicated + // [Product][google.cloud.retail.v2.Product] attributes. Notice that the + // rollup values are respect filter. For example, when filtering by + // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is + // returned. + // + // For textual and numerical attributes, the rollup values is a list of + // string or double values with type + // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if + // there are two variants with colors "red" and "blue", the rollup values + // are + // + // { key: "colorFamilies" + // value { + // list_value { + // values { string_value: "red" } + // values { string_value: "blue" } + // } + // } + // } + // + // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], the rollup + // values is a double value with type + // [google.protobuf.Value][google.protobuf.Value]. For example, + // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there + // are 10 variants in this product are available in the store "store1". + map variant_rollup_values = 5; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colorFamilies". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + } + + // The key for this facet. E.g., "colorFamilies" or "price" or + // "attributes.attr1". + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Information describing query expansion including whether expansion has + // occurred. + message QueryExpansionInfo { + // Bool describing whether query expansion has occurred. + bool expanded_query = 1; + + // Number of pinned results. This field will only be set when expansion + // happens and + // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] + // is set to true. + int64 pinned_result_count = 2; + } + + // A list of matched items. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.retail.v2.SearchResponse.results] returned + // by pagination may be less than the + // [total_size][google.cloud.retail.v2.SearchResponse.total_size] that + // matches. + int32 total_size = 3; + + // If spell correction applies, the corrected query. Otherwise, empty. + string corrected_query = 4; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this + // search, which enables accurate attribution of search model performance. + string attribution_token = 5; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.retail.v2.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 6; + + // Query expansion information for the returned results. + QueryExpansionInfo query_expansion_info = 7; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search will be performed, and only + // [redirect_uri][google.cloud.retail.v2.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] + // will be set in the response. + string redirect_uri = 10; + + // The fully qualified resource name of applied + // [controls](https://cloud.google.com/retail/docs/serving-control-rules). + repeated string applied_controls = 12; + + // The invalid + // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto new file mode 100644 index 00000000..8e21f8aa --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto @@ -0,0 +1,340 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// UserEvent captures all metadata information Retail API needs to know about +// how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // * `add-to-cart`: Products being added to cart. + // * `category-page-view`: Special pages such as sale or promotion pages + // viewed. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed. + // * `promotion-offered`: Promotion is offered to a user. + // * `promotion-not-offered`: Promotion is not offered to a user. + // * `purchase-complete`: User finishing a purchase. + // * `search`: Product search. + // * `shopping-cart-page-view`: User viewing a shopping cart. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A unique identifier for tracking visitors. + // + // For example, this could be implemented with an HTTP cookie, which should be + // able to uniquely identify a visitor on a single device. This unique + // identifier should not change if the visitor log in/out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analystics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the sesion_id: + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // visitor_id as prefix. + string session_id = 21; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.retail.v2.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups (e.g. using Retail API, using different + // recommendation models). + repeated string experiment_ids = 4; + + // Highly recommended for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be a valid + // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] + // for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. + // The value must be a valid + // [SearchResponse.attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] + // for user events that are the result of + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // This token enables us to accurately attribute page view or purchase back to + // the event and the particular predict response containing this + // clicked/purchased product. If user clicks on product K in the + // recommendation results, pass + // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] + // as a URL parameter to product K's page. When recording events on product + // K's page, log the + // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] + // to this field. + string attribution_token = 5; + + // The main product details related to the event. + // + // This field is required for the following event types: + // + // * `add-to-cart` + // * `detail-page-view` + // * `purchase-complete` + // * `search` + // + // In a `search` event, this field represents the products returned to the end + // user on the current page (the end user may have not finished browsing the + // whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [product_details][google.cloud.retail.v2.UserEvent.product_details] is + // desired. The end user may have not finished browsing the whole page yet. + repeated ProductDetail product_details = 6; + + // The main auto-completion details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionDetail completion_detail = 22; + + // Extra user event features to include in the recommendation model. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Retail API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // traffic_channel, which is how a user arrives at the site. Users can arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 7; + + // The ID or name of the associated shopping cart. This ID is used + // to associate multiple items added or present in the cart before purchase. + // + // This can only be set for `add-to-cart`, `purchase-complete`, or + // `shopping-cart-page-view` events. + string cart_id = 8; + + // A transaction represents the entire purchase transaction. + // + // Required for `purchase-complete` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + PurchaseTransaction purchase_transaction = 9; + + // The user's search query. + // + // See [SearchRequest.query][google.cloud.retail.v2.SearchRequest.query] for + // definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.retail.v2.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 10; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. + // + // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 16; + + // The order in which products are returned. + // + // See [SearchRequest.order_by][google.cloud.retail.v2.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 17; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See [SearchRequest.offset][google.cloud.retail.v2.SearchRequest.offset] for + // definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + int32 offset = 18; + + // The categories associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + // + // Required for `category-page-view` events. At least one of + // [search_query][google.cloud.retail.v2.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string page_categories = 11; + + // User information. + UserInfo user_info = 12; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 13; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string referrer_uri = 14; + + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string page_view_id = 15; +} + +// Detailed product information associated with a user event. +message ProductDetail { + // Required. [Product][google.cloud.retail.v2.Product] information. + // + // Required field(s): + // + // * [Product.id][google.cloud.retail.v2.Product.id] + // + // Optional override field(s): + // + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // + // If any supported optional fields are provided, we will treat them as a full + // override when looking up product information from the catalog. Thus, it is + // important to ensure that the overriding fields are accurate and + // complete. + // + // All other product fields are ignored and instead populated via catalog + // lookup after event ingestion. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Quantity of the product associated with the user event. + // + // For example, this field will be 2 if two products are added to the shopping + // cart for `purchase-complete` event. Required for `add-to-cart` and + // `purchase-complete` event types. + google.protobuf.Int32Value quantity = 2; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionDetail { + // Completion attribution token in + // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2.CompleteQueryResponse.attribution_token]. + string completion_attribution_token = 1; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion]. + string selected_suggestion = 2; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion] + // position, starting from 0. + int32 selected_position = 3; +} + +// A transaction represents the entire purchase transaction. +message PurchaseTransaction { + // The transaction ID with a length limit of 128 characters. + string id = 1; + + // Required. Total non-zero revenue or grand total associated with the + // transaction. This value include shipping, tax, or other adjustments to + // total revenue that you want to include as part of your revenue + // calculations. + float revenue = 2 [(google.api.field_behavior) = REQUIRED]; + + // All the taxes associated with the transaction. + float tax = 3; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = [revenue][google.cloud.retail.v2.PurchaseTransaction.revenue] - + // [tax][google.cloud.retail.v2.PurchaseTransaction.tax] - + // [cost][google.cloud.retail.v2.PurchaseTransaction.cost] + float cost = 4; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto new file mode 100644 index 00000000..4446906a --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto @@ -0,0 +1,190 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/import_config.proto"; +import "google/cloud/retail/v2/purge_config.proto"; +import "google/cloud/retail/v2/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for ingesting end user actions on the customer website. +service UserEventService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" + body: "user_event" + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Retail API JavaScript pixel and Google Tag + // Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }; + } + + // Deletes permanently all user events specified by the filter provided. + // Depending on the number of events specified by the filter, this operation + // could take hours or days to complete. To test a filter, use the list + // command first. + rpc PurgeUserEvents(PurgeUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.PurgeUserEventsResponse" + metadata_type: "google.cloud.retail.v2.PurgeMetadata" + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // Operation.response is of type ImportResponse. Note that it is + // possible for a subset of the items to be successfully inserted. + // Operation.metadata is of type ImportMetadata. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.ImportUserEventsResponse" + metadata_type: "google.cloud.retail.v2.ImportMetadata" + }; + } + + // Starts a user event rejoin operation with latest product catalog. Events + // will not be annotated with detailed product information if product is + // missing from the catalog at the time the user event is ingested, and these + // events are stored as unjoined events with a limited usage on training and + // serving. This method can be used to start a join operation on specified + // events with latest version of product catalog. It can also be used to + // correct events joined with the wrong product catalog. A rejoin operation + // can take hours or days to complete. + rpc RejoinUserEvents(RejoinUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "RejoinUserEventsResponse" + metadata_type: "RejoinUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User event to write. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent catalog name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // The URL including cgi-parameters but excluding the hash fragment with a + // length limit of 5,000 characters. This is often more useful than the + // referer URL, because many browsers only send the domain for 3rd party + // requests. + string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + int64 ets = 4; +} + +// Request message for RejoinUserEvents method. +message RejoinUserEventsRequest { + // The scope of user events to be rejoined with the latest product catalog. + // If the rejoining aims at reducing number of unjoined events, set + // UserEventRejoinScope to UNJOINED_EVENTS. + // If the rejoining aims at correcting product catalog information in joined + // events, set UserEventRejoinScope to JOINED_EVENTS. + // If all events needs to be rejoined, set UserEventRejoinScope to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. + enum UserEventRejoinScope { + // Rejoin all events with the latest product catalog, including both joined + // events and unjoined events. + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; + + // Only rejoin joined events with the latest product catalog. + JOINED_EVENTS = 1; + + // Only rejoin unjoined events with the latest product catalog. + UNJOINED_EVENTS = 2; + } + + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the user event rejoin to define the scope and range of the user + // events to be rejoined with the latest product catalog. Defaults to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + // invalid integer value. + UserEventRejoinScope user_event_rejoin_scope = 2; +} + +// Response message for RejoinUserEvents method. +message RejoinUserEventsResponse { + // Number of user events that were joined with latest product catalog. + int64 rejoined_user_events_count = 1; +} + +// Metadata for RejoinUserEvents method. +message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js new file mode 100644 index 00000000..fa840318 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js @@ -0,0 +1,58 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2_generated_CatalogService_GetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.getDefaultBranch(request); + console.log(response); + } + + callGetDefaultBranch(); + // [END retail_v2_generated_CatalogService_GetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js new file mode 100644 index 00000000..b5c79c51 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_CatalogService_ListCatalogs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The account resource name with an associated location. + * If the caller does not have permission to list + * Catalog google.cloud.retail.v2.Catalog s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Catalog google.cloud.retail.v2.Catalog s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListCatalogsResponse.next_page_token google.cloud.retail.v2.ListCatalogsResponse.next_page_token, + * received from a previous + * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callListCatalogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCatalogs(); + // [END retail_v2_generated_CatalogService_ListCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js new file mode 100644 index 00000000..f03f4c36 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2_generated_CatalogService_SetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * The final component of the resource name of a branch. + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * If there are no sufficient active products in the targeted branch and + * force google.cloud.retail.v2.SetDefaultBranchRequest.force is not set, a + * FAILED_PRECONDITION error is returned. + */ + // const branchId = 'abc123' + /** + * Some note on this request, this can be retrieved by + * CatalogService.GetDefaultBranch google.cloud.retail.v2.CatalogService.GetDefaultBranch + * before next valid default branch set occurs. + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const note = 'abc123' + /** + * If set to true, it permits switching to a branch with + * branch_id google.cloud.retail.v2.SetDefaultBranchRequest.branch_id even + * if it has no sufficient active products. + */ + // const force = true + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callSetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.setDefaultBranch(request); + console.log(response); + } + + callSetDefaultBranch(); + // [END retail_v2_generated_CatalogService_SetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js new file mode 100644 index 00000000..33d552b5 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.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(catalog) { + // [START retail_v2_generated_CatalogService_UpdateCatalog_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Catalog google.cloud.retail.v2.Catalog to update. + * If the caller does not have permission to update the + * Catalog google.cloud.retail.v2.Catalog, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the Catalog google.cloud.retail.v2.Catalog to update does not exist, + * a NOT_FOUND error is returned. + */ + // const catalog = {} + /** + * Indicates which fields in the provided + * Catalog google.cloud.retail.v2.Catalog to update. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCatalog() { + // Construct request + const request = { + catalog, + }; + + // Run request + const response = await retailClient.updateCatalog(request); + console.log(response); + } + + callUpdateCatalog(); + // [END retail_v2_generated_CatalogService_UpdateCatalog_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js b/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js new file mode 100644 index 00000000..738d1b40 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js @@ -0,0 +1,116 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog, query) { + // [START retail_v2_generated_CompletionService_CompleteQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Catalog for which the completion is performed. + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * Required. The query used to generate suggestions. + * The maximum number of allowed characters is 255. + */ + // const query = 'abc123' + /** + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see Tags for + * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + */ + // const languageCodes = 'abc123' + /** + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * Supported formats: + * * `UNKNOWN_DEVICE_TYPE` + * * `DESKTOP` + * * `MOBILE` + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + */ + // const deviceType = 'abc123' + /** + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * CompletionService.ImportCompletionData google.cloud.retail.v2.CompletionService.ImportCompletionData. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * Current supported values: + * * user-data + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + */ + // const dataset = 'abc123' + /** + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value CompletionConfig.max_suggestions . + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + catalog, + query, + }; + + // Run request + const response = await retailClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END retail_v2_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js b/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js new file mode 100644 index 00000000..4ccdcfe6 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.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, inputConfig) { + // [START retail_v2_generated_CompletionService_ImportCompletionData_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog which the suggestions dataset belongs to. + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callImportCompletionData() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importCompletionData(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportCompletionData(); + // [END retail_v2_generated_CompletionService_ImportCompletionData_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js b/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js new file mode 100644 index 00000000..af3de619 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js @@ -0,0 +1,161 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, userEvent) { + // [START retail_v2_generated_PredictionService_Predict_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see Managing + * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + */ + // const placement = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + */ + // const userEvent = {} + /** + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + */ + // const pageSize = 1234 + /** + * The previous PredictResponse.next_page_token. + */ + // const pageToken = 'abc123' + /** + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * Examples: + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + */ + // const filter = 'abc123' + /** + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + */ + // const validateOnly = true + /** + * Additional domain specific parameters for the predictions. + * Allowed values: + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + */ + // const params = 1234 + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + + // Imports the Retail library + const {PredictionServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new PredictionServiceClient(); + + async function callPredict() { + // Construct request + const request = { + placement, + userEvent, + }; + + // Run request + const response = await retailClient.predict(request); + console.log(response); + } + + callPredict(); + // [END retail_v2_generated_PredictionService_Predict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js b/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js new file mode 100644 index 00000000..79ea0522 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2_generated_ProductService_AddFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type. Duplicate + * IDs will be automatically ignored. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * If the total number of place IDs exceeds 2000 for this + * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type after + * adding, then the update will be rejected. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * Product google.cloud.retail.v2.Product is created. If set to false, a + * NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddFulfillmentPlaces(); + // [END retail_v2_generated_ProductService_AddFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js b/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js new file mode 100644 index 00000000..f0598e36 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js @@ -0,0 +1,99 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, localInventories) { + // [START retail_v2_generated_ProductService_AddLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + */ + // const localInventories = 1234 + /** + * Indicates which inventory fields in the provided list of + * LocalInventory google.cloud.retail.v2.LocalInventory to update. The + * field is updated to the provided value. + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const addMask = {} + /** + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the local inventory will still be processed and retained for at most + * 1 day and processed once the Product google.cloud.retail.v2.Product is + * created. If set to false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddLocalInventories() { + // Construct request + const request = { + product, + localInventories, + }; + + // Run request + const [operation] = await retailClient.addLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddLocalInventories(); + // [END retail_v2_generated_ProductService_AddLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js new file mode 100644 index 00000000..e64ffbdf --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, product, productId) { + // [START retail_v2_generated_ProductService_CreateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + */ + // const parent = 'abc123' + /** + * Required. The Product google.cloud.retail.v2.Product to create. + */ + // const product = {} + /** + * Required. The ID to use for the Product google.cloud.retail.v2.Product, + * which will become the final component of the + * Product.name google.cloud.retail.v2.Product.name. + * If the caller does not have permission to create the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * This field must be unique among all + * Product google.cloud.retail.v2.Product s with the same + * parent google.cloud.retail.v2.CreateProductRequest.parent. Otherwise, an + * ALREADY_EXISTS error is returned. + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const productId = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + productId, + }; + + // Run request + const response = await retailClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END retail_v2_generated_ProductService_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js new file mode 100644 index 00000000..7838dfa1 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.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(name) { + // [START retail_v2_generated_ProductService_DeleteProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to delete the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2.Product to delete does not exist, + * a NOT_FOUND error is returned. + * The Product google.cloud.retail.v2.Product to delete can neither be a + * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION + * Product google.cloud.retail.v2.Product member nor a + * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY + * Product google.cloud.retail.v2.Product with more than one + * variants google.cloud.retail.v2.Product.Type.VARIANT. Otherwise, an + * INVALID_ARGUMENT error is returned. + * All inventory information for the named + * Product google.cloud.retail.v2.Product will be deleted. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END retail_v2_generated_ProductService_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js new file mode 100644 index 00000000..007c35ea --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_ProductService_GetProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the requested Product google.cloud.retail.v2.Product does not exist, + * a NOT_FOUND error is returned. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END retail_v2_generated_ProductService_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js b/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js new file mode 100644 index 00000000..39cc5522 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js @@ -0,0 +1,93 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2_generated_ProductService_ImportProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. + */ + // const errorsConfig = {} + /** + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + */ + // const updateMask = {} + /** + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * Only supported when + * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode + * is set to `FULL`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callImportProducts() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProducts(); + // [END retail_v2_generated_ProductService_ImportProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js b/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js new file mode 100644 index 00000000..00b71a9a --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js @@ -0,0 +1,130 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_ProductService_ListProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * If the caller does not have permission to list + * Product google.cloud.retail.v2.Product s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Product google.cloud.retail.v2.Product s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT error is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListProductsResponse.next_page_token google.cloud.retail.v2.ListProductsResponse.next_page_token, + * received from a previous + * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2.ListProductsRequest.filter is unset. + * * List Product.Type.VARIANT google.cloud.retail.v2.Product.Type.VARIANT + * Product google.cloud.retail.v2.Product s sharing the same + * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY + * Product google.cloud.retail.v2.Product. For example: + * `primary_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2.Product s bundled in a + * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION + * Product google.cloud.retail.v2.Product. + * For example: + * `collection_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2.Product s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * If the specified + * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY + * Product google.cloud.retail.v2.Product or + * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION + * Product google.cloud.retail.v2.Product does not exist, a NOT_FOUND error + * is returned. + */ + // const filter = 'abc123' + /** + * The fields of Product google.cloud.retail.v2.Product to return in the + * responses. If not set or empty, the following fields are returned: + * * Product.name google.cloud.retail.v2.Product.name + * * Product.id google.cloud.retail.v2.Product.id + * * Product.title google.cloud.retail.v2.Product.title + * * Product.uri google.cloud.retail.v2.Product.uri + * * Product.images google.cloud.retail.v2.Product.images + * * Product.price_info google.cloud.retail.v2.Product.price_info + * * Product.brands google.cloud.retail.v2.Product.brands + * If "*" is provided, all fields are returned. + * Product.name google.cloud.retail.v2.Product.name is always returned no + * matter what mask is set. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const readMask = {} + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END retail_v2_generated_ProductService_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000..3be188b8 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js @@ -0,0 +1,111 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * Product google.cloud.retail.v2.Product is created. If set to false, a + * NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveFulfillmentPlaces(); + // [END retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js new file mode 100644 index 00000000..6332ed05 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, placeIds) { + // [START retail_v2_generated_ProductService_RemoveLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + */ + // const placeIds = 'abc123' + /** + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * Product google.cloud.retail.v2.Product is created. If set to false, a + * NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveLocalInventories() { + // Construct request + const request = { + product, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveLocalInventories(); + // [END retail_v2_generated_ProductService_RemoveLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js b/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js new file mode 100644 index 00000000..4f35c54e --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js @@ -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 +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inventory) { + // [START retail_v2_generated_ProductService_SetInventory_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The inventory information to update. The allowable fields to + * update are: + * * Product.price_info google.cloud.retail.v2.Product.price_info + * * Product.availability google.cloud.retail.v2.Product.availability + * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info + * The updated inventory fields must be specified in + * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask. + * If SetInventoryRequest.inventory.name is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2.Product named in + * Product.name google.cloud.retail.v2.Product.name, regardless of whether + * or not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2.Product to update does not have + * existing inventory information, the provided inventory information will be + * inserted. + * If the Product google.cloud.retail.v2.Product to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * SetInventoryRequest.set_time google.cloud.retail.v2.SetInventoryRequest.set_time. + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in SetInventoryRequest.inventory.fulfillment_info + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types to clear in + * SetInventoryRequest.inventory.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids + * The last update time is recorded for the following inventory fields: + * * Product.price_info google.cloud.retail.v2.Product.price_info + * * Product.availability google.cloud.retail.v2.Product.availability + * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info + * If a full overwrite of inventory information while ignoring timestamps is + * needed, UpdateProduct should be invoked instead. + */ + // const inventory = {} + /** + * Indicates which inventory fields in the provided + * Product google.cloud.retail.v2.Product to update. + * At least one field must be provided. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const setMask = {} + /** + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + */ + // const setTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product with name + * Product.name google.cloud.retail.v2.Product.name is not found, the + * inventory update will still be processed and retained for at most 1 day + * until the Product google.cloud.retail.v2.Product is created. If set to + * false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callSetInventory() { + // Construct request + const request = { + inventory, + }; + + // Run request + const [operation] = await retailClient.setInventory(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInventory(); + // [END retail_v2_generated_ProductService_SetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js new file mode 100644 index 00000000..359a30ef --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START retail_v2_generated_ProductService_UpdateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The product to update/create. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2.Product to update does not exist + * and + * allow_missing google.cloud.retail.v2.UpdateProductRequest.allow_missing + * is not set, a NOT_FOUND error is returned. + */ + // const product = {} + /** + * Indicates which fields in the provided + * Product google.cloud.retail.v2.Product to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, a new Product google.cloud.retail.v2.Product will be created. In + * this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await retailClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END retail_v2_generated_ProductService_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/search_service.search.js b/owl-bot-staging/v2/samples/generated/v2/search_service.search.js new file mode 100644 index 00000000..2083811f --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/search_service.search.js @@ -0,0 +1,260 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, visitorId) { + // [START retail_v2_generated_SearchService_Search_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + */ + // const placement = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + */ + // const query = 'abc123' + /** + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * This should be the same identifier as + * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * User information. + */ + // const userInfo = {} + /** + * Maximum number of Product google.cloud.retail.v2.Product s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * SearchResponse.next_page_token google.cloud.retail.v2.SearchResponse.next_page_token, + * received from a previous + * SearchService.Search google.cloud.retail.v2.SearchService.Search call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.retail.v2.SearchService.Search must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the Product google.cloud.retail.v2.Product s + * deemed by the API as relevant) in search results. This field is only + * considered if page_token google.cloud.retail.v2.SearchRequest.page_token + * is unset. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const filter = 'abc123' + /** + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * SearchRequest.canonical_filter google.cloud.retail.v2.SearchRequest.canonical_filter + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * See SearchRequest.filter google.cloud.retail.v2.SearchRequest.filter for + * more details about filter syntax. + */ + // const canonicalFilter = 'abc123' + /** + * The order in which products are returned. Products can be ordered by + * a field in an Product google.cloud.retail.v2.Product object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#order). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const orderBy = 'abc123' + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain products. See more details at this + * user guide (https://cloud.google.com/retail/docs/boosting). + * Notice that if both ServingConfig.boost_control_ids and + * SearchRequest.boost_spec are set, the boost conditions from both places + * are evaluated. If a search request matches multiple boost conditions, + * the final boost score is equal to the sum of the boost scores from all + * matched boost conditions. + */ + // const boostSpec = {} + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). + */ + // const queryExpansionSpec = {} + /** + * The keys to fetch and rollup the matching + * variant google.cloud.retail.v2.Product.Type.VARIANT + * Product google.cloud.retail.v2.Product s attributes, + * FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo or + * LocalInventory google.cloud.retail.v2.LocalInventory s attributes. The + * attributes from all the matching + * variant google.cloud.retail.v2.Product.Type.VARIANT + * Product google.cloud.retail.v2.Product s or + * LocalInventory google.cloud.retail.v2.LocalInventory s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * For FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * Supported keys are: + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * Product.inventories.attributes map. + * * attributes.key, where key is any key in the + * Product.attributes google.cloud.retail.v2.Product.attributes map. + * * pickupInStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "pickup-in-store". + * * shipToStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-1". + * * customFulfillment2.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-2". + * * customFulfillment3.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-3". + * * customFulfillment4.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-4". + * * customFulfillment5.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-5". + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + */ + // const variantRollupKeys = 'abc123' + /** + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * UserEvent.page_categories google.cloud.retail.v2.UserEvent.page_categories; + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : "Sales > 2017 Black Friday Deals". + */ + // const pageCategories = 'abc123' + /** + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + */ + // const searchMode = {} + /** + * The specification for personalization. + */ + // const personalizationSpec = {} + + // Imports the Retail library + const {SearchServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + placement, + visitorId, + }; + + // Run request + const iterable = await retailClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END retail_v2_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json new file mode 100644 index 00000000..6dbcb263 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json @@ -0,0 +1,1295 @@ +{ + "clientLibrary": { + "name": "nodejs-retail", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.retail.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "retail_v2_generated_CatalogService_ListCatalogs_async", + "title": "CatalogService listCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with the project.", + "canonical": true, + "file": "catalog_service.list_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ListCatalogsResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_UpdateCatalog_async", + "title": "CatalogService updateCatalog Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Catalog][google.cloud.retail.v2.Catalog]s.", + "canonical": true, + "file": "catalog_service.update_catalog.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": ".google.cloud.retail.v2.Catalog" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.Catalog", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_SetDefaultBranch_async", + "title": "CatalogService setDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", + "canonical": true, + "file": "catalog_service.set_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "branch_id", + "type": "TYPE_STRING" + }, + { + "name": "note", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_GetDefaultBranch_async", + "title": "CatalogService getDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] method under a specified parent catalog.", + "canonical": true, + "file": "catalog_service.get_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.GetDefaultBranchResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CompletionService_CompleteQuery_async", + "title": "CatalogService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 108, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "language_codes", + "type": "TYPE_STRING[]" + }, + { + "name": "device_type", + "type": "TYPE_STRING" + }, + { + "name": "dataset", + "type": "TYPE_STRING" + }, + { + "name": "max_suggestions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.retail.v2.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CompletionService_ImportCompletionData_async", + "title": "CatalogService importCompletionData Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.import_completion_data.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2.CompletionDataInputConfig" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2.CompletionServiceClient" + }, + "method": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_PredictionService_Predict_async", + "title": "CatalogService predict Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation prediction.", + "canonical": true, + "file": "prediction_service.predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 153, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2.PredictionService.Predict", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.retail.v2.PredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.retail.v2.PredictionServiceClient" + }, + "method": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2.PredictionService.Predict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.retail.v2.PredictionService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_CreateProduct_async", + "title": "CatalogService createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.retail.v2.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_GetProduct_async", + "title": "CatalogService getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2.ProductService.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2.ProductService.GetProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_ListProducts_async", + "title": "CatalogService listProducts Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Product][google.cloud.retail.v2.Product]s.", + "canonical": true, + "file": "product_service.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 122, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2.ProductService.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "read_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.ListProductsResponse", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2.ProductService.ListProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_UpdateProduct_async", + "title": "CatalogService updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.retail.v2.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_DeleteProduct_async", + "title": "CatalogService deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_ImportProducts_async", + "title": "CatalogService importProducts Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2.Product]s to be successfully updated.", + "canonical": true, + "file": "product_service.import_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2.ProductInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2.ImportErrorsConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_SetInventory_async", + "title": "CatalogService setInventory Sample", + "origin": "API_DEFINITION", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 116, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2.ProductService.SetInventory", + "async": true, + "parameters": [ + { + "name": "inventory", + "type": ".google.cloud.retail.v2.Product" + }, + { + "name": "set_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "set_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2.ProductService.SetInventory", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_AddFulfillmentPlaces_async", + "title": "CatalogService addFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async", + "title": "CatalogService removeFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 103, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_AddLocalInventories_async", + "title": "CatalogService addLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Updates local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 91, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "local_inventories", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "add_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_RemoveLocalInventories_async", + "title": "CatalogService removeLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Remove local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_SearchService_Search_async", + "title": "CatalogService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 252, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.retail.v2.UserInfo" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "canonical_filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "dynamic_facet_spec", + "type": ".google.cloud.retail.v2.SearchRequest.DynamicFacetSpec" + }, + { + "name": "boost_spec", + "type": ".google.cloud.retail.v2.SearchRequest.BoostSpec" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.retail.v2.SearchRequest.QueryExpansionSpec" + }, + { + "name": "variant_rollup_keys", + "type": "TYPE_STRING[]" + }, + { + "name": "page_categories", + "type": "TYPE_STRING[]" + }, + { + "name": "search_mode", + "type": ".google.cloud.retail.v2.SearchRequest.SearchMode" + }, + { + "name": "personalization_spec", + "type": ".google.cloud.retail.v2.SearchRequest.PersonalizationSpec" + } + ], + "resultType": ".google.cloud.retail.v2.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.retail.v2.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.retail.v2.SearchService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_WriteUserEvent_async", + "title": "CatalogService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2.UserEvent" + } + ], + "resultType": ".google.cloud.retail.v2.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_CollectUserEvent_async", + "title": "CatalogService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_PurgeUserEvents_async", + "title": "CatalogService purgeUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", + "canonical": true, + "file": "user_event_service.purge_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_ImportUserEvents_async", + "title": "CatalogService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2.UserEventInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2.ImportErrorsConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_RejoinUserEvents_async", + "title": "CatalogService rejoinUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", + "canonical": true, + "file": "user_event_service.rejoin_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event_rejoin_scope", + "type": ".google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js new file mode 100644 index 00000000..40992711 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2_generated_UserEventService_CollectUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + */ + // const userEvent = 'abc123' + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + */ + // const uri = 'abc123' + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + */ + // const ets = 1234 + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END retail_v2_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js new file mode 100644 index 00000000..fa18d38d --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2_generated_UserEventService_ImportUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. `projects/1234/locations/global/catalogs/default_catalog` + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorsConfig = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END retail_v2_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js new file mode 100644 index 00000000..0a008d5d --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js @@ -0,0 +1,90 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2_generated_UserEventService_PurgeUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * * `eventType`: Double quoted + * UserEvent.event_type google.cloud.retail.v2.UserEvent.event_type string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * Examples: + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * The filtering fields are assumed to have an implicit AND. + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + */ + // const force = true + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callPurgeUserEvents() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeUserEvents(); + // [END retail_v2_generated_UserEventService_PurgeUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000..925f96b6 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_UserEventService_RejoinUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + */ + // const userEventRejoinScope = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callRejoinUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await retailClient.rejoinUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRejoinUserEvents(); + // [END retail_v2_generated_UserEventService_RejoinUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js new file mode 100644 index 00000000..6df073a3 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2_generated_UserEventService_WriteUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END retail_v2_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/src/index.ts b/owl-bot-staging/v2/src/index.ts new file mode 100644 index 00000000..28988c03 --- /dev/null +++ b/owl-bot-staging/v2/src/index.ts @@ -0,0 +1,35 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 v2 from './v2'; +const CatalogServiceClient = v2.CatalogServiceClient; +type CatalogServiceClient = v2.CatalogServiceClient; +const CompletionServiceClient = v2.CompletionServiceClient; +type CompletionServiceClient = v2.CompletionServiceClient; +const PredictionServiceClient = v2.PredictionServiceClient; +type PredictionServiceClient = v2.PredictionServiceClient; +const ProductServiceClient = v2.ProductServiceClient; +type ProductServiceClient = v2.ProductServiceClient; +const SearchServiceClient = v2.SearchServiceClient; +type SearchServiceClient = v2.SearchServiceClient; +const UserEventServiceClient = v2.UserEventServiceClient; +type UserEventServiceClient = v2.UserEventServiceClient; +export {v2, CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient}; +export default {v2, CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_client.ts b/owl-bot-staging/v2/src/v2/catalog_service_client.ts new file mode 100644 index 00000000..c8d68a6b --- /dev/null +++ b/owl-bot-staging/v2/src/v2/catalog_service_client.ts @@ -0,0 +1,1058 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/catalog_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './catalog_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for managing catalog configuration. + * @class + * @memberof v2 + */ +export class CatalogServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + catalogServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CatalogServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CatalogServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listCatalogs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.CatalogService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.catalogServiceStub) { + return this.catalogServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.CatalogService. + this.catalogServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.CatalogService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.CatalogService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const catalogServiceStubMethods = + ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch']; + for (const methodName of catalogServiceStubMethods) { + const callPromise = this.catalogServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.catalogServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Updates the {@link google.cloud.retail.v2.Catalog|Catalog}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Catalog} request.catalog + * Required. The {@link google.cloud.retail.v2.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.Catalog|Catalog}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Catalog|Catalog} to update does not exist, + * a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.Catalog|Catalog} to update. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2.Catalog}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.update_catalog.js + * region_tag:retail_v2_generated_CatalogService_UpdateCatalog_async + */ + updateCatalog( + request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|undefined, {}|undefined + ]>; + updateCatalog( + request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog.name': request.catalog!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCatalog(request, options, callback); + } +/** + * Set a specified branch id as default branch. API methods such as + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search}, + * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct}, + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as + * default, setting + * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` + * as {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.branchId + * The final component of the resource name of a branch. + * + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * + * If there are no sufficient active products in the targeted branch and + * {@link google.cloud.retail.v2.SetDefaultBranchRequest.force|force} is not set, a + * FAILED_PRECONDITION error is returned. + * @param {string} request.note + * Some note on this request, this can be retrieved by + * {@link google.cloud.retail.v2.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} + * before next valid default branch set occurs. + * + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {boolean} request.force + * If set to true, it permits switching to a branch with + * {@link google.cloud.retail.v2.SetDefaultBranchRequest.branch_id|branch_id} even + * if it has no sufficient active products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.set_default_branch.js + * region_tag:retail_v2_generated_CatalogService_SetDefaultBranch_async + */ + setDefaultBranch( + request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|undefined, {}|undefined + ]>; + setDefaultBranch( + request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultBranch(request, options, callback); + } +/** + * Get which branch is currently default branch set by + * {@link google.cloud.retail.v2.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} + * method under a specified parent catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2.GetDefaultBranchResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.get_default_branch.js + * region_tag:retail_v2_generated_CatalogService_GetDefaultBranch_async + */ + getDefaultBranch( + request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|undefined, {}|undefined + ]>; + getDefaultBranch( + request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + callback: Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } + + /** + * Lists all the {@link google.cloud.retail.v2.Catalog|Catalog}s associated with + * the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2.Catalog}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogs( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.ICatalog[], + protos.google.cloud.retail.v2.IListCatalogsRequest|null, + protos.google.cloud.retail.v2.IListCatalogsResponse + ]>; + listCatalogs( + request: protos.google.cloud.retail.v2.IListCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2.ICatalog>): void; + listCatalogs( + request: protos.google.cloud.retail.v2.IListCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2.ICatalog>): void; + listCatalogs( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2.ICatalog>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2.ICatalog>): + Promise<[ + protos.google.cloud.retail.v2.ICatalog[], + protos.google.cloud.retail.v2.IListCatalogsRequest|null, + protos.google.cloud.retail.v2.IListCatalogsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listCatalogs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2.Catalog} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogsStream( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.createStream( + this.innerApiCalls.listCatalogs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCatalogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Catalog]{@link google.cloud.retail.v2.Catalog}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.list_catalogs.js + * region_tag:retail_v2_generated_CatalogService_ListCatalogs_async + */ + listCatalogsAsync( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.asyncIterate( + this.innerApiCalls['listCatalogs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.catalogServiceStub && !this._terminated) { + return this.catalogServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_client_config.json b/owl-bot-staging/v2/src/v2/catalog_service_client_config.json new file mode 100644 index 00000000..dd5a76fa --- /dev/null +++ b/owl-bot-staging/v2/src/v2/catalog_service_client_config.json @@ -0,0 +1,55 @@ +{ + "interfaces": { + "google.cloud.retail.v2.CatalogService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListCatalogs": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCatalog": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "SetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json b/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/completion_service_client.ts b/owl-bot-staging/v2/src/v2/completion_service_client.ts new file mode 100644 index 00000000..086944c6 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/completion_service_client.ts @@ -0,0 +1,701 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Auto-completion service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2 + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importCompletionDataResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportCompletionDataResponse') as gax.protobuf.Type; + const importCompletionDataMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importCompletionData: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importCompletionDataResponse.decode.bind(importCompletionDataResponse), + importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.CompletionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.CompletionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.CompletionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const completionServiceStubMethods = + ['completeQuery', 'importCompletionData']; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Required. Catalog for which the completion is performed. + * + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string} request.visitorId + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {string[]} request.languageCodes + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see [Tags for + * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + * @param {string} request.deviceType + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * + * Supported formats: + * + * * `UNKNOWN_DEVICE_TYPE` + * + * * `DESKTOP` + * + * * `MOBILE` + * + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + * @param {string} request.dataset + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * {@link google.cloud.retail.v2.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * + * Current supported values: + * + * * user-data + * + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + * @param {number} request.maxSuggestions + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value {@link |CompletionConfig.max_suggestions}. + * + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2.CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/completion_service.complete_query.js + * region_tag:retail_v2_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|undefined, {}|undefined + ]>; + completeQuery( + request: protos.google.cloud.retail.v2.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request: protos.google.cloud.retail.v2.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + +/** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog which the suggestions dataset belongs to. + * + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2.CompletionDataInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/completion_service.import_completion_data.js + * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async + */ + importCompletionData( + request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importCompletionData( + request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importCompletionData(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importCompletionData()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/completion_service.import_completion_data.js + * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async + */ + async checkImportCompletionDataProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/completion_service_client_config.json b/owl-bot-staging/v2/src/v2/completion_service_client_config.json new file mode 100644 index 00000000..a6bffad0 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/completion_service_client_config.json @@ -0,0 +1,45 @@ +{ + "interfaces": { + "google.cloud.retail.v2.CompletionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ImportCompletionData": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/completion_service_proto_list.json b/owl-bot-staging/v2/src/v2/completion_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/completion_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/gapic_metadata.json b/owl-bot-staging/v2/src/v2/gapic_metadata.json new file mode 100644 index 00000000..e2fe1b36 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/gapic_metadata.json @@ -0,0 +1,345 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.retail.v2", + "libraryPackage": "@google-cloud/retail", + "services": { + "CatalogService": { + "clients": { + "grpc": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + } + } + }, + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "ProductService": { + "clients": { + "grpc": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/index.ts b/owl-bot-staging/v2/src/v2/index.ts new file mode 100644 index 00000000..79cde8aa --- /dev/null +++ b/owl-bot-staging/v2/src/v2/index.ts @@ -0,0 +1,24 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CatalogServiceClient} from './catalog_service_client'; +export {CompletionServiceClient} from './completion_service_client'; +export {PredictionServiceClient} from './prediction_service_client'; +export {ProductServiceClient} from './product_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2/src/v2/prediction_service_client.ts b/owl-bot-staging/v2/src/v2/prediction_service_client.ts new file mode 100644 index 00000000..a38a7013 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/prediction_service_client.ts @@ -0,0 +1,603 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/prediction_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './prediction_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for making recommendation prediction. + * @class + * @memberof v2 + */ +export class PredictionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + predictionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PredictionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PredictionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.PredictionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.predictionServiceStub) { + return this.predictionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.PredictionService. + this.predictionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.PredictionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.PredictionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const predictionServiceStubMethods = + ['predict']; + for (const methodName of predictionServiceStubMethods) { + const callPromise = this.predictionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.predictionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Makes a recommendation prediction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see [Managing + * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + * @param {google.cloud.retail.v2.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * @param {number} request.pageSize + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * @param {string} request.pageToken + * The previous PredictResponse.next_page_token. + * @param {string} request.filter + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * + * Examples: + * + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * @param {boolean} request.validateOnly + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the predictions. + * + * Allowed values: + * + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2.PredictResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/prediction_service.predict.js + * region_tag:retail_v2_generated_PredictionService_Predict_async + */ + predict( + request?: protos.google.cloud.retail.v2.IPredictRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|undefined, {}|undefined + ]>; + predict( + request: protos.google.cloud.retail.v2.IPredictRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request: protos.google.cloud.retail.v2.IPredictRequest, + callback: Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request?: protos.google.cloud.retail.v2.IPredictRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.predictionServiceStub && !this._terminated) { + return this.predictionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/prediction_service_client_config.json b/owl-bot-staging/v2/src/v2/prediction_service_client_config.json new file mode 100644 index 00000000..9ab95d31 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/prediction_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2.PredictionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json b/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/product_service_client.ts b/owl-bot-staging/v2/src/v2/product_service_client.ts new file mode 100644 index 00000000..e61bc990 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/product_service_client.ts @@ -0,0 +1,2210 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/product_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.retail.v2.Product|Product} information + * of the customer's website. + * @class + * @memberof v2 + */ +export class ProductServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProductServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportProductsResponse') as gax.protobuf.Type; + const importProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; + const setInventoryResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.SetInventoryResponse') as gax.protobuf.Type; + const setInventoryMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.SetInventoryMetadata') as gax.protobuf.Type; + const addFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddFulfillmentPlacesResponse') as gax.protobuf.Type; + const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; + const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; + const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; + const addLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddLocalInventoriesResponse') as gax.protobuf.Type; + const addLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddLocalInventoriesMetadata') as gax.protobuf.Type; + const removeLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveLocalInventoriesResponse') as gax.protobuf.Type; + const removeLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductsResponse.decode.bind(importProductsResponse), + importProductsMetadata.decode.bind(importProductsMetadata)), + setInventory: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInventoryResponse.decode.bind(setInventoryResponse), + setInventoryMetadata.decode.bind(setInventoryMetadata)), + addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), + addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), + removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), + removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), + addLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), + addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), + removeLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), + removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.ProductService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.productServiceStub) { + return this.productServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.ProductService. + this.productServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ProductService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.ProductService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const productServiceStubMethods = + ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; + for (const methodName of productServiceStubMethods) { + const callPromise = this.productServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.productServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + * @param {google.cloud.retail.v2.Product} request.product + * Required. The {@link google.cloud.retail.v2.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the {@link google.cloud.retail.v2.Product|Product}, + * which will become the final component of the + * {@link google.cloud.retail.v2.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * This field must be unique among all + * {@link google.cloud.retail.v2.Product|Product}s with the same + * {@link google.cloud.retail.v2.CreateProductRequest.parent|parent}. Otherwise, an + * ALREADY_EXISTS error is returned. + * + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.create_product.js + * region_tag:retail_v2_generated_ProductService_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.retail.v2.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.retail.v2.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.retail.v2.ICreateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.retail.v2.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link google.cloud.retail.v2.Product|Product} does not exist, + * a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.get_product.js + * region_tag:retail_v2_generated_ProductService_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.retail.v2.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.retail.v2.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.retail.v2.IGetProductRequest, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.retail.v2.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Updates a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Product} request.product + * Required. The product to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Product|Product} to update does not exist + * and + * {@link google.cloud.retail.v2.UpdateProductRequest.allow_missing|allow_missing} + * is not set, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.Product|Product} to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, a new {@link google.cloud.retail.v2.Product|Product} will be created. In + * this situation, `update_mask` is ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.update_product.js + * region_tag:retail_v2_generated_ProductService_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.retail.v2.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.retail.v2.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.retail.v2.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.retail.v2.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Deletes a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Product|Product} to delete does not exist, + * a NOT_FOUND error is returned. + * + * The {@link google.cloud.retail.v2.Product|Product} to delete can neither be a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} member nor a + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} with more than one + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link google.cloud.retail.v2.Product|Product} will be deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.delete_product.js + * region_tag:retail_v2_generated_ProductService_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.retail.v2.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.retail.v2.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.retail.v2.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.retail.v2.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } + +/** + * Bulk import of multiple {@link google.cloud.retail.v2.Product|Product}s. + * + * Request processing may be synchronous. No partial updating is supported. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * {@link google.cloud.retail.v2.Product|Product}s to be successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + * @param {string} request.requestId + * Deprecated. This field has no effect. + * @param {google.cloud.retail.v2.ProductInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + * @param {google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * {@link google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * + * Only supported when + * {@link google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} + * is set to `FULL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.import_products.js + * region_tag:retail_v2_generated_ProductService_ImportProducts_async + */ + importProducts( + request?: protos.google.cloud.retail.v2.IImportProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProducts( + request: protos.google.cloud.retail.v2.IImportProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request: protos.google.cloud.retail.v2.IImportProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request?: protos.google.cloud.retail.v2.IImportProductsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.import_products.js + * region_tag:retail_v2_generated_ProductService_ImportProducts_async + */ + async checkImportProductsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates inventory information for a + * {@link google.cloud.retail.v2.Product|Product} while respecting the last update + * timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, updates are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct}, the + * specified inventory field value(s) will overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update time for the specified inventory fields will be overwritten to the + * time of the + * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} or + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2.CreateProductRequest.product|CreateProductRequest.product}, + * then any pre-existing inventory information for this product will be used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information will be preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2.ProductService.SetInventory|SetInventory}, + * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Product} request.inventory + * Required. The inventory information to update. The allowable fields to + * update are: + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.Product|Product} named in + * {@link google.cloud.retail.v2.Product.name|Product.name}, regardless of whether + * or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Product|Product} to update does not have + * existing inventory information, the provided inventory information will be + * inserted. + * + * If the {@link google.cloud.retail.v2.Product|Product} to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * {@link google.cloud.retail.v2.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. + * + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} + * + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link |SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} + * + * The last update time is recorded for the following inventory fields: + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, {@link |UpdateProduct} should be invoked instead. + * @param {google.protobuf.FieldMask} request.setMask + * Indicates which inventory fields in the provided + * {@link google.cloud.retail.v2.Product|Product} to update. + * + * At least one field must be provided. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.setTime + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} with name + * {@link google.cloud.retail.v2.Product.name|Product.name} is not found, the + * inventory update will still be processed and retained for at most 1 day + * until the {@link google.cloud.retail.v2.Product|Product} is created. If set to + * false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.set_inventory.js + * region_tag:retail_v2_generated_ProductService_SetInventory_async + */ + setInventory( + request?: protos.google.cloud.retail.v2.ISetInventoryRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInventory( + request: protos.google.cloud.retail.v2.ISetInventoryRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request: protos.google.cloud.retail.v2.ISetInventoryRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request?: protos.google.cloud.retail.v2.ISetInventoryRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'inventory.name': request.inventory!.name || '', + }); + this.initialize(); + return this.innerApiCalls.setInventory(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInventory()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.set_inventory.js + * region_tag:retail_v2_generated_ProductService_SetInventory_async + */ + async checkSetInventoryProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally adds place IDs to + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}. Duplicate + * IDs will be automatically ignored. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * If the total number of place IDs exceeds 2000 for this + * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type} after + * adding, then the update will be rejected. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async + */ + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async + */ + async checkAddFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally removes place IDs from a + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async + */ + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async + */ + async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates local inventory information for a + * {@link google.cloud.retail.v2.Product|Product} at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} has no + * effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {number[]} request.localInventories + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + * @param {google.protobuf.FieldMask} request.addMask + * Indicates which inventory fields in the provided list of + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory} to update. The + * field is updated to the provided value. + * + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the local inventory will still be processed and retained for at most + * 1 day and processed once the {@link google.cloud.retail.v2.Product|Product} is + * created. If set to false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_local_inventories.js + * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async + */ + addLocalInventories( + request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addLocalInventories( + request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_local_inventories.js + * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async + */ + async checkAddLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Remove local inventory information for a + * {@link google.cloud.retail.v2.Product|Product} at a list of places at a removal + * timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} has no + * effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {string[]} request.placeIds + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_local_inventories.js + * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async + */ + removeLocalInventories( + request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeLocalInventories( + request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_local_inventories.js + * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async + */ + async checkRemoveLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.retail.v2.Product|Product}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2.Product|Product}s sharing the same + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} or + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error + * is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2.Product.name|Product.name} + * * {@link google.cloud.retail.v2.Product.id|Product.id} + * * {@link google.cloud.retail.v2.Product.title|Product.title} + * * {@link google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2.Product.images|Product.images} + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no + * matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.retail.v2.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IProduct[], + protos.google.cloud.retail.v2.IListProductsRequest|null, + protos.google.cloud.retail.v2.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.retail.v2.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2.IProduct>): void; + listProducts( + request: protos.google.cloud.retail.v2.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2.IProduct>): void; + listProducts( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2.IProduct>): + Promise<[ + protos.google.cloud.retail.v2.IProduct[], + protos.google.cloud.retail.v2.IListProductsRequest|null, + protos.google.cloud.retail.v2.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2.Product|Product}s sharing the same + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} or + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error + * is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2.Product.name|Product.name} + * * {@link google.cloud.retail.v2.Product.id|Product.id} + * * {@link google.cloud.retail.v2.Product.title|Product.title} + * * {@link google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2.Product.images|Product.images} + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no + * matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2.Product|Product}s sharing the same + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} or + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error + * is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2.Product.name|Product.name} + * * {@link google.cloud.retail.v2.Product.id|Product.id} + * * {@link google.cloud.retail.v2.Product.title|Product.title} + * * {@link google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2.Product.images|Product.images} + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no + * matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.retail.v2.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/product_service.list_products.js + * region_tag:retail_v2_generated_ProductService_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.productServiceStub && !this._terminated) { + return this.productServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/product_service_client_config.json b/owl-bot-staging/v2/src/v2/product_service_client_config.json new file mode 100644 index 00000000..32245ac6 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/product_service_client_config.json @@ -0,0 +1,99 @@ +{ + "interfaces": { + "google.cloud.retail.v2.ProductService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "GetProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ListProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "UpdateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "DeleteProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportProducts": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "SetInventory": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/product_service_proto_list.json b/owl-bot-staging/v2/src/v2/product_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/product_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/search_service_client.ts b/owl-bot-staging/v2/src/v2/search_service_client.ts new file mode 100644 index 00000000..7303493f --- /dev/null +++ b/owl-bot-staging/v2/src/v2/search_service_client.ts @@ -0,0 +1,1243 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2 + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + search: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.SearchService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.SearchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.SearchService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const searchServiceStubMethods = + ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for + * more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both {@link |ServingConfig.boost_control_ids} and + * [SearchRequest.boost_spec] are set, the boost conditions from both places + * are evaluated. If a search request matches multiple boost conditions, + * the final boost score is equal to the sum of the boost scores from all + * matched boost conditions. + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s attributes, + * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.retail.v2.ISearchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2.ISearchRequest|null, + protos.google.cloud.retail.v2.ISearchResponse + ]>; + search( + request: protos.google.cloud.retail.v2.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): void; + search( + request: protos.google.cloud.retail.v2.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): void; + search( + request?: protos.google.cloud.retail.v2.ISearchRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): + Promise<[ + protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2.ISearchRequest|null, + protos.google.cloud.retail.v2.ISearchResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for + * more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both {@link |ServingConfig.boost_control_ids} and + * [SearchRequest.boost_spec] are set, the boost conditions from both places + * are evaluated. If a search request matches multiple boost conditions, + * the final boost score is equal to the sum of the boost scores from all + * matched boost conditions. + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s attributes, + * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.retail.v2.ISearchRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `search`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for + * more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both {@link |ServingConfig.boost_control_ids} and + * [SearchRequest.boost_spec] are set, the boost conditions from both places + * are evaluated. If a search request matches multiple boost conditions, + * the final boost score is equal to the sum of the boost scores from all + * matched boost conditions. + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s attributes, + * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/search_service.search.js + * region_tag:retail_v2_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.retail.v2.ISearchRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/search_service_client_config.json b/owl-bot-staging/v2/src/v2/search_service_client_config.json new file mode 100644 index 00000000..5132c12d --- /dev/null +++ b/owl-bot-staging/v2/src/v2/search_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2.SearchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/search_service_proto_list.json b/owl-bot-staging/v2/src/v2/search_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/search_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/user_event_service_client.ts b/owl-bot-staging/v2/src/v2/user_event_service_client.ts new file mode 100644 index 00000000..18b3688e --- /dev/null +++ b/owl-bot-staging/v2/src/v2/user_event_service_client.ts @@ -0,0 +1,966 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on the customer website. + * @class + * @memberof v2 + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const purgeUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.PurgeUserEventsResponse') as gax.protobuf.Type; + const purgeUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.PurgeMetadata') as gax.protobuf.Type; + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportUserEventsResponse') as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; + const rejoinUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RejoinUserEventsResponse') as gax.protobuf.Type; + const rejoinUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RejoinUserEventsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), + purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata)), + rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), + rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.UserEventService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.UserEventService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.UserEventService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const userEventServiceStubMethods = + ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2.UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.write_user_event.js + * region_tag:retail_v2_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|undefined, {}|undefined + ]>; + writeUserEvent( + request: protos.google.cloud.retail.v2.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request: protos.google.cloud.retail.v2.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } +/** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.collect_user_event.js + * region_tag:retail_v2_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|undefined, {}|undefined + ]>; + collectUserEvent( + request: protos.google.cloud.retail.v2.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request: protos.google.cloud.retail.v2.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + +/** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + * @param {string} request.filter + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * + * * `eventType`: Double quoted + * {@link google.cloud.retail.v2.UserEvent.event_type|UserEvent.event_type} string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * + * Examples: + * + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * + * The filtering fields are assumed to have an implicit AND. + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.purge_user_events.js + * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async + */ + purgeUserEvents( + request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeUserEvents( + request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.purgeUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.purge_user_events.js + * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async + */ + async checkPurgeUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. `projects/1234/locations/global/catalogs/default_catalog` + * @param {google.cloud.retail.v2.UserEventInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.import_user_events.js + * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importUserEvents( + request: protos.google.cloud.retail.v2.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request: protos.google.cloud.retail.v2.IImportUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.import_user_events.js + * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a user event rejoin operation with latest product catalog. Events + * will not be annotated with detailed product information if product is + * missing from the catalog at the time the user event is ingested, and these + * events are stored as unjoined events with a limited usage on training and + * serving. This method can be used to start a join operation on specified + * events with latest version of product catalog. It can also be used to + * correct events joined with the wrong product catalog. A rejoin operation + * can take hours or days to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js + * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async + */ + rejoinUserEvents( + request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rejoinUserEvents( + request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.rejoinUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rejoinUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js + * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async + */ + async checkRejoinUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/user_event_service_client_config.json b/owl-bot-staging/v2/src/v2/user_event_service_client_config.json new file mode 100644 index 00000000..a3938b37 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/user_event_service_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.retail.v2.UserEventService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "CollectUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "PurgeUserEvents": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportUserEvents": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "RejoinUserEvents": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json b/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..ffbb2218 --- /dev/null +++ b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const retail = require('@google-cloud/retail'); + +function main() { + const catalogServiceClient = new retail.CatalogServiceClient(); + const completionServiceClient = new retail.CompletionServiceClient(); + const predictionServiceClient = new retail.PredictionServiceClient(); + const productServiceClient = new retail.ProductServiceClient(); + const searchServiceClient = new retail.SearchServiceClient(); + const userEventServiceClient = new retail.UserEventServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..285edd82 --- /dev/null +++ b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts @@ -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. ** + +import {CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient} from '@google-cloud/retail'; + +// check that the client class type name can be used +function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { + client.close(); +} +function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { + client.close(); +} +function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { + client.close(); +} +function doStuffWithProductServiceClient(client: ProductServiceClient) { + client.close(); +} +function doStuffWithSearchServiceClient(client: SearchServiceClient) { + client.close(); +} +function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const catalogServiceClient = new CatalogServiceClient(); + doStuffWithCatalogServiceClient(catalogServiceClient); + // check that the client instance can be created + const completionServiceClient = new CompletionServiceClient(); + doStuffWithCompletionServiceClient(completionServiceClient); + // check that the client instance can be created + const predictionServiceClient = new PredictionServiceClient(); + doStuffWithPredictionServiceClient(predictionServiceClient); + // check that the client instance can be created + const productServiceClient = new ProductServiceClient(); + doStuffWithProductServiceClient(productServiceClient); + // check that the client instance can be created + const searchServiceClient = new SearchServiceClient(); + doStuffWithSearchServiceClient(searchServiceClient); + // check that the client instance can be created + const userEventServiceClient = new UserEventServiceClient(); + doStuffWithUserEventServiceClient(userEventServiceClient); +} + +main(); diff --git a/owl-bot-staging/v2/system-test/install.ts b/owl-bot-staging/v2/system-test/install.ts new file mode 100644 index 00000000..8ec45222 --- /dev/null +++ b/owl-bot-staging/v2/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/v2/test/gapic_catalog_service_v2.ts b/owl-bot-staging/v2/test/gapic_catalog_service_v2.ts new file mode 100644 index 00000000..8a1bf5ac --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_catalog_service_v2.ts @@ -0,0 +1,903 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as catalogserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2.CatalogServiceClient', () => { + it('has servicePath', () => { + const servicePath = catalogserviceModule.v2.CatalogServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = catalogserviceModule.v2.CatalogServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = catalogserviceModule.v2.CatalogServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new catalogserviceModule.v2.CatalogServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + await client.initialize(); + assert(client.catalogServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.catalogServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('updateCatalog', () => { + it('invokes updateCatalog without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); + const [response] = await client.updateCatalog(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCatalog( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.ICatalog|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCatalog with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCatalog(request), expectedError); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCatalog(request), expectedError); + }); + }); + + describe('setDefaultBranch', () => { + it('invokes setDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultBranch( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultBranch(request), expectedError); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultBranch(request), expectedError); + }); + }); + + describe('getDefaultBranch', () => { + it('invokes getDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.getDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDefaultBranch( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IGetDefaultBranchResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDefaultBranch(request), expectedError); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDefaultBranch(request), expectedError); + }); + }); + + describe('listCatalogs', () => { + it('invokes listCatalogs without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.listCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogs without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCatalogs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.ICatalog[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCatalogs with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCatalogs(request), expectedError); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogsStream without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCatalogsStream with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.ICatalog[] = []; + const iterable = client.listCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_completion_service_v2.ts b/owl-bot-staging/v2/test/gapic_completion_service_v2.ts new file mode 100644 index 00000000..c15e5c3f --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_completion_service_v2.ts @@ -0,0 +1,503 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as completionserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2.CompletionServiceClient', () => { + it('has servicePath', () => { + const servicePath = completionserviceModule.v2.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = completionserviceModule.v2.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v2.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new completionserviceModule.v2.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.ICompleteQueryResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('importCompletionData', () => { + it('invokes importCompletionData without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); + const [operation] = await client.importCompletionData(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCompletionData( + request, + (err?: Error|null, + result?: LROperation|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.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importCompletionData with call error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importCompletionData(request), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData with LRO error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportCompletionDataProgress without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportCompletionDataProgress with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts b/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts new file mode 100644 index 00000000..efa20c2b --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts @@ -0,0 +1,343 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as predictionserviceModule from '../src'; + +import {protobuf} 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('v2.PredictionServiceClient', () => { + it('has servicePath', () => { + const servicePath = predictionserviceModule.v2.PredictionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = predictionserviceModule.v2.PredictionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = predictionserviceModule.v2.PredictionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new predictionserviceModule.v2.PredictionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + await client.initialize(); + assert(client.predictionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.predictionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('predict', () => { + it('invokes predict without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCall(expectedResponse); + const [response] = await client.predict(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.predict( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IPredictResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes predict with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict with closed client', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); + request.placement = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_product_service_v2.ts b/owl-bot-staging/v2/test/gapic_product_service_v2.ts new file mode 100644 index 00000000..aafd946a --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_product_service_v2.ts @@ -0,0 +1,1846 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as productserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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('v2.ProductServiceClient', () => { + it('has servicePath', () => { + const servicePath = productserviceModule.v2.ProductServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productserviceModule.v2.ProductServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productserviceModule.v2.ProductServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productserviceModule.v2.ProductServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productserviceModule.v2.ProductServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + await client.initialize(); + assert(client.productServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('importProducts', () => { + it('invokes importProducts without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProducts( + request, + (err?: Error|null, + result?: LROperation|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.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProducts with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProducts(request), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductsProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductsProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInventory', () => { + it('invokes setInventory without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInventory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInventory( + request, + (err?: Error|null, + result?: LROperation|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.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setInventory with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInventory(request), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkSetInventoryProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInventoryProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInventoryProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addFulfillmentPlaces', () => { + it('invokes addFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeFulfillmentPlaces', () => { + it('invokes removeFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addLocalInventories', () => { + it('invokes addLocalInventories without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.addLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addLocalInventories with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addLocalInventories(request), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeLocalInventories', () => { + it('invokes removeLocalInventories without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeLocalInventories with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeLocalInventories(request), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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.retail.v2.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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.retail.v2.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_search_service_v2.ts b/owl-bot-staging/v2/test/gapic_search_service_v2.ts new file mode 100644 index 00000000..44857ae4 --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_search_service_v2.ts @@ -0,0 +1,570 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2.SearchServiceClient', () => { + it('has servicePath', () => { + const servicePath = searchserviceModule.v2.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = searchserviceModule.v2.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v2.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v2.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts b/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts new file mode 100644 index 00000000..2cb56664 --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts @@ -0,0 +1,888 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as usereventserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2.UserEventServiceClient', () => { + it('has servicePath', () => { + const servicePath = usereventserviceModule.v2.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = usereventserviceModule.v2.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v2.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v2.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IUserEvent|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('purgeUserEvents', () => { + it('invokes purgeUserEvents without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeUserEvents with call error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeUserEvents(request), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rejoinUserEvents', () => { + it('invokes rejoinUserEvents without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.rejoinUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejoinUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes rejoinUserEvents with call error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRejoinUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRejoinUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/tsconfig.json b/owl-bot-staging/v2/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v2/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/v2/webpack.config.js b/owl-bot-staging/v2/webpack.config.js new file mode 100644 index 00000000..f2c58f25 --- /dev/null +++ b/owl-bot-staging/v2/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CatalogService', + filename: './catalog-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v2alpha/.eslintignore b/owl-bot-staging/v2alpha/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v2alpha/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v2alpha/.eslintrc.json b/owl-bot-staging/v2alpha/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v2alpha/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v2alpha/.gitignore b/owl-bot-staging/v2alpha/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v2alpha/.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/v2alpha/.jsdoc.js b/owl-bot-staging/v2alpha/.jsdoc.js new file mode 100644 index 00000000..19729810 --- /dev/null +++ b/owl-bot-staging/v2alpha/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v2alpha/.mocharc.js b/owl-bot-staging/v2alpha/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v2alpha/.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/v2alpha/.prettierrc.js b/owl-bot-staging/v2alpha/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v2alpha/.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/v2alpha/README.md b/owl-bot-staging/v2alpha/README.md new file mode 100644 index 00000000..822c4573 --- /dev/null +++ b/owl-bot-staging/v2alpha/README.md @@ -0,0 +1 @@ +Retail: Nodejs Client diff --git a/owl-bot-staging/v2alpha/linkinator.config.json b/owl-bot-staging/v2alpha/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v2alpha/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/v2alpha/package.json b/owl-bot-staging/v2alpha/package.json new file mode 100644 index 00000000..94071ee3 --- /dev/null +++ b/owl-bot-staging/v2alpha/package.json @@ -0,0 +1,71 @@ +{ + "name": "@google-cloud/retail", + "version": "0.1.0", + "description": "Retail client for Node.js", + "repository": "googleapis/nodejs-retail", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google retail", + "retail", + "catalog service", + "completion service", + "control service", + "prediction service", + "product service", + "search service", + "serving config service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto new file mode 100644 index 00000000..9b3d8cb0 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto @@ -0,0 +1,397 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configures what level the product should be uploaded with regards to +// how users will be send events and how predictions will be made. +message ProductLevelConfig { + // The type of [Product][google.cloud.retail.v2alpha.Product]s allowed to be + // ingested into the catalog. Acceptable values are: + // + // * `primary` (default): You can ingest + // [Product][google.cloud.retail.v2alpha.Product]s of all types. When + // ingesting a [Product][google.cloud.retail.v2alpha.Product], its type will + // default to + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // if unset. + // * `variant`: You can only ingest + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s. + // This means + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] + // cannot be empty. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `variant` and + // [merchant_center_product_id_field][google.cloud.retail.v2alpha.ProductLevelConfig.merchant_center_product_id_field] + // is `itemGroupId`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string ingestion_product_type = 1; + + // Which field of [Merchant Center + // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be + // imported as [Product.id][google.cloud.retail.v2alpha.Product.id]. + // Acceptable values are: + // + // * `offerId` (default): Import `offerId` as the product ID. + // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail + // API will choose one item from the ones with the same `itemGroupId`, and + // use it to represent the item group. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `itemGroupId` and + // [ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] + // is `variant`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string merchant_center_product_id_field = 2; +} + +// Catalog level attribute config for an attribute. For example, if customers +// want to enable/disable facet for a specific attribute. +message CatalogAttribute { + // The type of an attribute. + enum AttributeType { + // The type of the attribute is unknown. + // + // Used when type cannot be derived from attribute that is not + // [in_use][google.cloud.retail.v2alpha.CatalogAttribute.in_use]. + UNKNOWN = 0; + + // Textual attribute. + TEXTUAL = 1; + + // Numerical attribute. + NUMERICAL = 2; + } + + // The status of the indexable option of a catalog attribute. + enum IndexableOption { + // Value used when unset. Defaults to + // [INDEXABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. + INDEXABLE_OPTION_UNSPECIFIED = 0; + + // Indexable option enabled for an attribute. + INDEXABLE_ENABLED = 1; + + // Indexable option disabled for an attribute. + INDEXABLE_DISABLED = 2; + } + + // The status of the dynamic facetable option of a catalog attribute. + enum DynamicFacetableOption { + // Value used when unset. Defaults to + // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; + + // Dynamic facetable option enabled for an attribute. + DYNAMIC_FACETABLE_ENABLED = 1; + + // Dynamic facetable option disabled for an attribute. + DYNAMIC_FACETABLE_DISABLED = 2; + } + + // The status of the searchable option of a catalog attribute. + enum SearchableOption { + // Value used when unset. Defaults to + // [SEARCHABLE_DISABLED][google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Indicates whether this attribute has been used by any + // products. `True` if at least one + // [Product][google.cloud.retail.v2alpha.Product] is using this attribute in + // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. + // Otherwise, this field is `False`. + // + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] can be + // pre-loaded by using [AddCatalogAttribute][], [ImportCatalogAttributes][], + // or [UpdateAttributesConfig][] APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s. + // + // Only [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that + // are not in use by products can be deleted. + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that are + // in use by products cannot be deleted; however, their configuration + // properties will reset to default values upon removal request. + // + // After catalog changes, it takes about 10 minutes for this field to update. + bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The type of this attribute. This is derived from the attribute + // in [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. + AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values + // are indexed so that it can be filtered, faceted, or boosted in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + IndexableOption indexable_option = 5; + + // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic + // facet. Could only be DYNAMIC_FACETABLE_DISABLED if + // [CatalogAttribute.indexable_option][google.cloud.retail.v2alpha.CatalogAttribute.indexable_option] + // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. + DynamicFacetableOption dynamic_facetable_option = 6; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values + // are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values + // will not be searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], + // as there are no text values associated to numerical attributes. + SearchableOption searchable_option = 7; +} + +// Catalog level attribute config. +message AttributesConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/AttributesConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }; + + // Required. Immutable. The fully qualified resource name of the attribute + // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Enable attribute(s) config at catalog level. + // For example, indexable, dynamic_facetable, or searchable for each + // attribute. + // + // The key is catalog attribute's name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // + // The maximum number of catalog attributes allowed in a request is 1000. + map catalog_attributes = 2; + + // Output only. The + // [AttributeConfigLevel][google.cloud.retail.v2alpha.AttributeConfigLevel] + // used for this catalog. + AttributeConfigLevel attribute_config_level = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Catalog level autocomplete config for customers to customize autocomplete +// feature's settings. +message CompletionConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/CompletionConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }; + + // Required. Immutable. Fully qualified name + // `projects/*/locations/*/catalogs/*/completionConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Specifies the matching order for autocomplete suggestions, e.g., a query + // consisting of 'sh' with 'out-of-order' specified would suggest "women's + // shoes", whereas a query of 'red s' with 'exact-prefix' specified would + // suggest "red shoes". Currently supported values: + // + // * 'out-of-order' + // * 'exact-prefix' + // + // Default value: 'exact-prefix'. + string matching_order = 2; + + // The maximum number of autocomplete suggestions returned per term. The + // maximum allowed max suggestions is 20. Default value is 20. If left unset + // or set to 0, then will fallback to default value. + int32 max_suggestions = 3; + + // The minimum number of characters needed to be typed in order to get + // suggestions. Default value is 2. If left unset or set to 0, then will + // fallback to default value. + int32 min_prefix_length = 4; + + // If set to true, the auto learning function is enabled. Auto learning uses + // user data to generate suggestions using ML techniques. Default value is + // false. Only after enabling auto learning can users use `cloud-retail` + // data in + // [CompleteQueryRequest][google.cloud.retail.v2alpha.CompleteQueryRequest]. + bool auto_learning = 11; + + // Output only. The input config for the import of the source data that + // contains the autocomplete phrases uploaded by the customer. + CompletionDataInputConfig suggestions_input_config = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest suggestion terms + // list import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_suggestions_import_operation = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The input config for the import of the source data that + // contains the / autocomplete denylist phrases uploaded by the customer. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. LRO corresponding to the latest denylist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_denylist_import_operation = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The input config for the import of the source data that + // contains the autocomplete allowlist phrases uploaded by the customer. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. LRO corresponding to the latest allowlist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_allowlist_import_operation = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Represents a link between a Merchant Center account and a branch. +// Once a link is established, products from the linked merchant center account +// will be streamed to the linked branch. +message MerchantCenterLink { + // Required. The linked [Merchant center account + // id](https://developers.google.com/shopping-content/guides/accountstatuses). + // The account must be a standalone account or a sub-account of a MCA. + int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch id (e.g. 0/1/2) within this catalog that products from + // merchant_center_account_id are streamed to. When updating this field, an + // empty value will use the currently configured default branch. However, + // changing the default branch later on won't change the linked branch here. + // + // A single branch id can only have one linked merchant center account id. + string branch_id = 2; + + // String representing the destination to import for, all if left empty. + // List of possible values can be found here. + // [https://support.google.com/merchants/answer/7501026] + // List of allowed string values: + // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory + // _ads", "Free_listings", "Free_local_listings" + // NOTE: The string values are case sensitive. + repeated string destinations = 3; + + // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 + // code. List of values can be found + // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) + // under the `region` tag. If left blank no region filtering will be + // performed. + // + // Example value: `US`. + string region_code = 4; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // ISO 639-1. + // + // This specifies the language of offers in Merchant Center that will be + // accepted. If empty no language filtering will be performed. + // + // Example value: `en`. + string language_code = 5; +} + +// Configures Merchant Center linking. +// Links contained in the config will be used to sync data from a Merchant +// Center account to a Cloud Retail branch. +message MerchantCenterLinkingConfig { + // Links between Merchant Center accounts and branches. + repeated MerchantCenterLink links = 1; +} + +// The catalog configuration. +message Catalog { + option (google.api.resource) = { + type: "retail.googleapis.com/Catalog" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" + }; + + // Required. Immutable. The fully qualified resource name of the catalog. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The catalog display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. The product level configuration. + ProductLevelConfig product_level_config = 4 + [(google.api.field_behavior) = REQUIRED]; + + // The Merchant Center linking configuration. + // Once a link is added, the data stream from Merchant Center to Cloud Retail + // will be enabled automatically. The requester must have access to the + // merchant center account in order to make changes to this field. + MerchantCenterLinkingConfig merchant_center_linking_config = 6; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto new file mode 100644 index 00000000..6ecab725 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto @@ -0,0 +1,478 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/catalog.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for managing catalog configuration. +service CatalogService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated + // with the project. + rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*}/catalogs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s. + rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { + option (google.api.http) = { + patch: "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}" + body: "catalog" + }; + option (google.api.method_signature) = "catalog,update_mask"; + } + + // Set a specified branch id as default branch. API methods such as + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] + // will treat requests using "default_branch" to the actual branch id set as + // default. + // + // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + // default, setting + // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + // to setting + // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/1`. + // + // Using multiple branches can be useful when developers would like + // to have a staging branch to test and verify for future usage. When it + // becomes ready, developers switch on the staging branch using this API while + // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + // as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] + // to route the traffic to this staging branch. + // + // CAUTION: If you have live predict/search traffic, switching the default + // branch could potentially cause outages if the ID space of the new branch is + // very different from the old one. + // + // More specifically: + // + // * PredictionService will only return product IDs from branch {newBranch}. + // * SearchService will only return product IDs from branch {newBranch} + // (if branch is not explicitly set). + // * UserEventService will only join events with products from branch + // {newBranch}. + rpc SetDefaultBranch(SetDefaultBranchRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" + body: "*" + }; + option (google.api.method_signature) = "catalog"; + } + + // Get which branch is currently default branch set by + // [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] + // method under a specified parent catalog. + rpc GetDefaultBranch(GetDefaultBranchRequest) + returns (GetDefaultBranchResponse) { + option (google.api.http) = { + get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + }; + option (google.api.method_signature) = "catalog"; + } + + // Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]. + rpc GetCompletionConfig(GetCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/completionConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s. + rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + patch: "/v2alpha/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" + body: "completion_config" + }; + option (google.api.method_signature) = "completion_config,update_mask"; + } + + // Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + rpc GetAttributesConfig(GetAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + // + // The catalog attributes in the request will be updated in the catalog, or + // inserted if they do not exist. Existing catalog attributes not included in + // the request will remain unchanged. Attributes that are assigned to + // products, but do not exist at the catalog level, are always included in the + // response. The product attribute is assigned default values for missing + // catalog attribute fields, e.g., searchable and dynamic facetable options. + rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + patch: "/v2alpha/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" + body: "attributes_config" + }; + option (google.api.method_signature) = "attributes_config,update_mask"; + } + + // Adds the specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to + // add already exists, an ALREADY_EXISTS error is returned. + rpc AddCatalogAttribute(AddCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" + body: "*" + }; + } + + // Removes the specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to + // remove does not exist, a NOT_FOUND error is returned. + rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" + body: "*" + }; + } + + // Replaces the specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by + // updating the catalog attribute with the same + // [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. + // + // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to + // replace does not exist, a NOT_FOUND error is returned. + rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" + body: "*" + }; + } +} + +// Request for +// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] +// method. +message ListCatalogsRequest { + // Required. The account resource name with an associated location. + // + // If the caller does not have permission to list + // [Catalog][google.cloud.retail.v2alpha.Catalog]s under this location, + // regardless of whether or not this location exists, a PERMISSION_DENIED + // error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of [Catalog][google.cloud.retail.v2alpha.Catalog]s to + // return. If unspecified, defaults to 50. The maximum allowed value is 1000. + // Values above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 2; + + // A page token + // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token], + // received from a previous + // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; +} + +// Response for +// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] +// method. +message ListCatalogsResponse { + // All the customer's [Catalog][google.cloud.retail.v2alpha.Catalog]s. + repeated Catalog catalogs = 1; + + // A token that can be sent as + // [ListCatalogsRequest.page_token][google.cloud.retail.v2alpha.ListCatalogsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request for +// [CatalogService.UpdateCatalog][google.cloud.retail.v2alpha.CatalogService.UpdateCatalog] +// method. +message UpdateCatalogRequest { + // Required. The [Catalog][google.cloud.retail.v2alpha.Catalog] to update. + // + // If the caller does not have permission to update the + // [Catalog][google.cloud.retail.v2alpha.Catalog], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Catalog][google.cloud.retail.v2alpha.Catalog] to update does not + // exist, a NOT_FOUND error is returned. + Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Catalog][google.cloud.retail.v2alpha.Catalog] to update. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message to set a specified branch as new default_branch. +message SetDefaultBranchRequest { + // Full resource name of the catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // The final component of the resource name of a branch. + // + // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // If there are no sufficient active products in the targeted branch and + // [force][google.cloud.retail.v2alpha.SetDefaultBranchRequest.force] is not + // set, a FAILED_PRECONDITION error is returned. + string branch_id = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Some note on this request, this can be retrieved by + // [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch] + // before next valid default branch set occurs. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string note = 3; + + // If set to true, it permits switching to a branch with + // [branch_id][google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id] + // even if it has no sufficient active products. + bool force = 4; +} + +// Request message to show which branch is currently the default branch. +message GetDefaultBranchRequest { + // The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response message of +// [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch]. +message GetDefaultBranchResponse { + // Full resource name of the branch id currently set as default branch. + string branch = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // The time when this branch is set to default. + google.protobuf.Timestamp set_time = 2; + + // This corresponds to + // [SetDefaultBranchRequest.note][google.cloud.retail.v2alpha.SetDefaultBranchRequest.note] + // field, when this branch was set as default. + string note = 3; +} + +// Request for +// [CatalogService.GetCompletionConfig][google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig] +// method. +message GetCompletionConfigRequest { + // Required. Full CompletionConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/CompletionConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig] +// method. +message UpdateCompletionConfigRequest { + // Required. The + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. + // + // If the caller does not have permission to update the + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig], then a + // PERMISSION_DENIED error is returned. + // + // If the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to + // update does not exist, a NOT_FOUND error is returned. + CompletionConfig completion_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. + // The following are the only supported fields: + // + // * [CompletionConfig.matching_order][google.cloud.retail.v2alpha.CompletionConfig.matching_order] + // * [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions] + // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length] + // * [CompletionConfig.auto_learning][google.cloud.retail.v2alpha.CompletionConfig.auto_learning] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.GetAttributesConfig][google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig] +// method. +message GetAttributesConfigRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig] +// method. +message UpdateAttributesConfigRequest { + // Required. The + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. + AttributesConfig attributes_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. + // The following is the only supported field: + // + // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute] +// method. +message AddCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute] +// method. +message RemoveCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The attribute name key of the + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove. + string key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute] +// method. +message ReplaceCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The updated + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to update. + // The following are NOT supported: + // + // * [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 3; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto new file mode 100644 index 00000000..ae33d3f6 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto @@ -0,0 +1,761 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// At which level we offer configuration for attributes. +enum AttributeConfigLevel { + // Value used when unset. Defaults to + // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2alpha.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; + + // At this level, we honor the attribute configurations set in + // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; + + // At this level, we honor the attribute configurations set in + // [CatalogConfig.attribute_configs][google.cloud.retail.v2alpha.CatalogConfig.attribute_configs]. + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; +} + +// The type of solution. +enum SolutionType { + // Default value. + SOLUTION_TYPE_UNSPECIFIED = 0; + + // Used for Recommendations AI. + SOLUTION_TYPE_RECOMMENDATION = 1; + + // Used for Retail Search. + SOLUTION_TYPE_SEARCH = 2; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. Defaults to + // [SEARCH][]. + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; + + // Search use case. Expects the traffic has a non-empty + // [query][google.cloud.retail.v2alpha.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_SEARCH = 1; + + // Browse use case. Expects the traffic has an empty + // [query][google.cloud.retail.v2alpha.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_BROWSE = 2; +} + +// Metadata that is used to define a condition that triggers an action. +// A valid condition must specify at least one of 'query_terms' or +// 'products_filter'. If multiple fields are specified, the condition is met if +// all the fields are satisfied e.g. if a set of query terms and product_filter +// are set, then only items matching the product_filter for requests with a +// query matching the query terms wil get boosted. +message Condition { + // Query terms that we want to match on. + message QueryTerm { + // The value of the term to match on. + // Value cannot be empty. + // Value can have at most 3 terms if specified as a partial match. Each + // space separated string is considered as one term. + // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not + // allowed for partial match. + string value = 1; + + // Whether this is supposed to be a full or partial match. + bool full_match = 2; + } + + // Used for time-dependent conditions. + // Example: Want to have rule applied for week long sale. + message TimeRange { + // Start of time range. Range is inclusive. + google.protobuf.Timestamp start_time = 1; + + // End of time range. Range is inclusive. + google.protobuf.Timestamp end_time = 2; + } + + // A list (up to 10 entries) of terms to match the query on. If not + // specified, match all queries. + // If many query terms are specified, the condition + // is matched if any of the terms is a match (i.e. using the OR operator). + repeated QueryTerm query_terms = 1; + + // Range of time(s) specifying when Condition is active. + // Condition true if any time range matches. + repeated TimeRange active_time_range = 3; +} + +// A rule is a condition-action pair +// * A condition defines when a rule is to be triggered. +// * An action specifies what occurs on that trigger. +// Currently only boost rules are supported. +// Currently only supported by the search endpoint. +message Rule { + // A boost action to apply to results matching condition specified above. + message BoostAction { + // Strength of the condition boost, which must be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 1; + + // The filter can have a max size of 5000 characters. + // An expression which specifies which products to apply an action to. + // The syntax and supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string products_filter = 2; + } + + // * Rule Condition: + // - No [Condition][query_terms] provided is a global match. + // - 1 or more [Condition][query_terms] provided is combined with OR + // operator. + // * Action Input: The request query and filter that will be applied to the + // retrieved products, in addition to any filters already provided with the + // SearchRequest. The AND operator is used to combine the query's existing + // filters with the filter rule(s). NOTE: May result in 0 results when + // filters conflict. + // * Action Result: Filters the returned objects to be ONLY those that passed + // the filter. + message FilterAction { + // A filter to apply on the matching condition results. Supported features: + // + // * [filter][google.cloud.retail.v2alpha.Rule.FilterAction.filter] must be + // set. + // * Filter syntax is identical to + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]. + // See more + // details at the Retail Search + // [user guide](/retail/search/docs/filter-and-order#filter). + // * To filter products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string filter = 1; + } + + // Redirects a shopper to a specific page. + // * Rule Condition: + // - Must specify [Condition][query_terms]. + // * Action Input: Request Query + // * Action Result: Redirects shopper to provided uri. + message RedirectAction { + // URL must have length equal or less than 2000 characters. + string redirect_uri = 1; + } + + // Creates a set of terms that will be treated as synonyms of each other. + // Example: synonyms of "sneakers" and "shoes". + // * "sneakers" will use a synonym of "shoes". + // * "shoes" will use a synonym of "sneakers". + message TwowaySynonymsAction { + // Defines a set of synonyms. + // Can specify up to 100 synonyms. + // Must specify at least 2 synonyms. + repeated string synonyms = 1; + } + + // Maps a set of terms to a set of synonyms. + // Set of synonyms will be treated as synonyms of each query term only. + // `query_terms` will not be treated as synonyms of each other. + // Example: "sneakers" will use a synonym of "shoes". + // "shoes" will not use a synonym of "sneakers". + message OnewaySynonymsAction { + // Terms from the search query. + // Will treat synonyms as their synonyms. + // Not themselves synonyms of the synonyms. + // Can specify up to 100 terms. + repeated string query_terms = 3; + + // Defines a set of synonyms. + // Cannot contain duplicates. + // Can specify up to 100 synonyms. + repeated string synonyms = 4; + + // Will be [deprecated = true] post migration; + repeated string oneway_terms = 2; + } + + // Prevents `query_term` from being associated with specified terms during + // search. + // Example: Don't associate "gShoe" and "cheap". + message DoNotAssociateAction { + // Terms from the search query. + // Will not consider do_not_associate_terms for search if in search query. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Cannot contain duplicates or the query term. + // Can specify up to 100 terms. + repeated string do_not_associate_terms = 3; + + // Will be [deprecated = true] post migration; + repeated string terms = 1; + } + + // Replaces a term in the query. Multiple replacement candidates can be + // specified. All `query_terms` will be replaced with the replacement term. + // Example: Replace "gShoe" with "google shoe". + message ReplacementAction { + // Terms from the search query. + // Will be replaced by replacement term. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Term that will be used for replacement. + string replacement_term = 3; + + // Will be [deprecated = true] post migration; + string term = 1; + } + + // Prevents a term in the query from being used in search. + // Example: Don't search for "shoddy". + message IgnoreAction { + // Terms to ignore in the search query. + repeated string ignore_terms = 1; + } + + // An action must be provided. + oneof action { + // A boost action. + BoostAction boost_action = 2; + + // Redirects a shopper to a specific page. + RedirectAction redirect_action = 3; + + // Treats specific term as a synonym with a group of terms. + // Group of terms will not be treated as synonyms with the specific term. + OnewaySynonymsAction oneway_synonyms_action = 6; + + // Prevents term from being associated with other terms. + DoNotAssociateAction do_not_associate_action = 7; + + // Replaces specific terms in the query. + ReplacementAction replacement_action = 8; + + // Ignores specific terms from query during search. + IgnoreAction ignore_action = 9; + + // Filters results. + FilterAction filter_action = 10; + + // Treats a set of terms as synonyms of one another. + TwowaySynonymsAction twoway_synonyms_action = 11; + } + + // Required. The condition that triggers the rule. + // If the condition is empty, the rule will always apply. + Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// An intended audience of the [Product][google.cloud.retail.v2alpha.Product] +// for whom it's sold. +message Audience { + // The genders of the audience. Strongly encouraged to use the standard + // values: "male", "female", "unisex". + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [gender](https://support.google.com/merchants/answer/6324479). Schema.org + // property + // [Product.audience.suggestedGender](https://schema.org/suggestedGender). + repeated string genders = 1; + + // The age groups of the audience. Strongly encouraged to use the standard + // values: "newborn" (up to 3 months old), "infant" (3–12 months old), + // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically + // teens or older). + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [age_group](https://support.google.com/merchants/answer/6324463). + // Schema.org property + // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and + // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). + repeated string age_groups = 2; +} + +// The color information of a [Product][google.cloud.retail.v2alpha.Product]. +message ColorInfo { + // The standard color families. Strongly recommended to use the following + // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", + // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and + // "Mixed". Normally it is expected to have only 1 color family. May consider + // using single "Mixed" instead of multiple values. + // + // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string color_families = 1; + + // The color display names, which may be different from standard color family + // names, such as the color aliases used in the website frontend. Normally + // it is expected to have only 1 color. May consider using single "Mixed" + // instead of multiple values. + // + // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string colors = 2; +} + +// A custom attribute that is not explicitly modeled in +// [Product][google.cloud.retail.v2alpha.Product]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated double numbers = 2; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. + // + // Only set if type [text][google.cloud.retail.v2alpha.CustomAttribute.text] + // is set. Otherwise, a INVALID_ARGUMENT error is returned. + optional bool searchable = 3; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // indexed, so that it can be filtered, faceted or boosted in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter], + // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2alpha.SearchRequest.boost_spec] + // for more details. + optional bool indexable = 4; +} + +// Fulfillment information, such as the store IDs for in-store pickup or region +// IDs for different shipping methods. +message FulfillmentInfo { + // The fulfillment type, including commonly used types (such as pickup in + // store and same day delivery), and custom types. Customers have to map + // custom types to their display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + string type = 1; + + // The IDs for this [type][google.cloud.retail.v2alpha.FulfillmentInfo.type], + // such as the store IDs for + // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // or the region IDs for + // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2alpha.FulfillmentInfo.type]. + // + // A maximum of 3000 values are allowed. Each value must be a string with a + // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such + // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string place_ids = 2; +} + +// [Product][google.cloud.retail.v2alpha.Product] image. Recommendations AI and +// Retail Search do not use product images to improve prediction and search +// results. However, product images can be returned in results, and are shown in +// prediction or search previews in the console. +message Image { + // Required. URI of the image. + // + // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Height of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 height = 2; + + // Width of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 width = 3; +} + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are set, then + // the lower bound is negative infinity. + // + // This field must be not larger than + // [max][google.cloud.retail.v2alpha.Interval.max]. Otherwise, an + // INVALID_ARGUMENT error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are set, then + // the upper bound is positive infinity. + // + // This field must be not smaller than + // [min][google.cloud.retail.v2alpha.Interval.min]. Otherwise, an + // INVALID_ARGUMENT error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// The price information of a [Product][google.cloud.retail.v2alpha.Product]. +message PriceInfo { + // The price range of all + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. + message PriceRange { + // The inclusive + // [Product.pricing_info.price][google.cloud.retail.v2alpha.PriceInfo.price] + // interval of all + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. + Interval price = 1; + + // The inclusive + // [Product.pricing_info.original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] + // internal of all + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. + Interval original_price = 2; + } + + // The 3-letter currency code defined in [ISO + // 4217](https://www.iso.org/iso-4217-currency-codes.html). + // + // If this field is an unrecognizable currency code, an INVALID_ARGUMENT + // error is returned. + // + // The + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s with the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] + // must share the same + // [currency_code][google.cloud.retail.v2alpha.PriceInfo.currency_code]. + // Otherwise, a FAILED_PRECONDITION error is returned. + string currency_code = 1; + + // Price of the product. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). Schema.org + // property [Offer.price](https://schema.org/price). + float price = 2; + + // Price of the product without any discount. If zero, by default set to be + // the [price][google.cloud.retail.v2alpha.PriceInfo.price]. + float original_price = 3; + + // The costs associated with the sale of a particular product. Used for gross + // profit reporting. + // + // * Profit = [price][google.cloud.retail.v2alpha.PriceInfo.price] - + // [cost][google.cloud.retail.v2alpha.PriceInfo.cost] + // + // Google Merchant Center property + // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). + float cost = 4; + + // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] + // starts to be effective. This can be set as a future timestamp, and the + // [price][google.cloud.retail.v2alpha.PriceInfo.price] is only used for + // search after + // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. + // If so, the + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is + // used before + // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. + // + // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is + // always effective because it will cause additional latency during search. + google.protobuf.Timestamp price_effective_time = 5; + + // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] + // stops to be effective. The + // [price][google.cloud.retail.v2alpha.PriceInfo.price] is used for search + // before + // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. + // If this field is set, the + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is + // used after + // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. + // + // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is + // always effective because it will cause additional latency during search. + google.protobuf.Timestamp price_expire_time = 6; + + // Output only. The price range of all the child + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s grouped together on the + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]. Only populated for + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. + // Do not set this field in API requests. + PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The rating of a [Product][google.cloud.retail.v2alpha.Product]. +message Rating { + // The total number of ratings. This value is independent of the value of + // [rating_histogram][google.cloud.retail.v2alpha.Rating.rating_histogram]. + // + // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 rating_count = 1; + + // The average rating of the [Product][google.cloud.retail.v2alpha.Product]. + // + // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is + // returned. + float average_rating = 2; + + // List of rating counts per rating value (index = rating - 1). The list is + // empty if there is no rating. If the list is non-empty, its size is + // always 5. Otherwise, an INVALID_ARGUMENT error is returned. + // + // For example, [41, 14, 13, 47, 303]. It means that the + // [Product][google.cloud.retail.v2alpha.Product] got 41 ratings with 1 star, + // 14 ratings with 2 star, and so on. + repeated int32 rating_histogram = 3; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. + // + // Always use a hashed value for this ID. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string user_id = 1; + + // The end user's IP address. This field is used to extract location + // information for personalization. + // + // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 + // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This should not be set when: + // + // * setting + // [SearchRequest.user_info][google.cloud.retail.v2alpha.SearchRequest.user_info]. + // * using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] + // is set. + string ip_address = 2; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][google.cloud.retail.v2alpha.SearchResponse.sponsored_results]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] + // is set. + string user_agent = 3; + + // True if the request is made directly from the end user, in which case the + // [ip_address][google.cloud.retail.v2alpha.UserInfo.ip_address] and + // [user_agent][google.cloud.retail.v2alpha.UserInfo.user_agent] can be + // populated from the HTTP request. This flag should be set only if the API + // request is made directly from the end user such as a mobile app (and not if + // a gateway or a server is processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent]. + bool direct_user_request = 4; +} + +// The inventory information at a place (e.g. a store) identified +// by a place ID. +message LocalInventory { + // The place ID for the current set of inventory information. + string place_id = 1; + + // Product price and cost information. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 2; + + // Additional local inventory attributes, for example, store name, promotion + // tags, etc. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * At most 30 attributes are allowed. + // * The key must be a UTF-8 encoded string with a length limit of 32 + // characters. + // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, + // key0LikeThis or KEY_1_LIKE_THIS. + // * The attribute values must be of the same type (text or number). + // * Only 1 value is allowed for each attribute. + // * For text values, the length limit is 256 UTF-8 characters. + // * The attribute does not support search. The `searchable` field should be + // unset or set to false. + // * The max summed total bytes of custom attribute keys and values per + // product is 5MiB. + map attributes = 3; + + // Input only. Supported fulfillment types. Valid fulfillment type values + // include commonly used types (such as pickup in store and same day + // delivery), and custom types. Customers have to map custom types to their + // display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string fulfillment_types = 4 + [(google.api.field_behavior) = INPUT_ONLY]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto new file mode 100644 index 00000000..a91aa618 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto @@ -0,0 +1,199 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Auto-completion service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service CompletionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified prefix with keyword suggestions. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }; + } + + // Bulk import of processed completion dataset. + // + // Request processing is asynchronous. Partial updating is not supported. + // + // The operation is successfully finished only after the imported suggestions + // are indexed successfully and ready for serving. The process takes hours. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc ImportCompletionData(ImportCompletionDataRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/completionData:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.ImportCompletionDataResponse" + metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" + }; + } +} + +// Auto-complete parameters. +message CompleteQueryRequest { + // Required. Catalog for which the completion is performed. + // + // Full resource name of catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The query used to generate suggestions. + // + // The maximum number of allowed characters is 255. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required field. A unique identifier for tracking visitors. For example, + // this could be implemented with an HTTP cookie, which should be able to + // uniquely identify a visitor on a single device. This unique identifier + // should not change if the visitor logs in or out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 7; + + // The language filters applied to the output suggestions. If set, it should + // contain the language of the query. If not set, suggestions are returned + // without considering language restrictions. This is the BCP-47 language + // code, such as "en-US" or "sr-Latn". For more information, see [Tags for + // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + // number of language codes is 3. + repeated string language_codes = 3; + + // The device type context for completion suggestions. + // It is useful to apply different suggestions on different device types, e.g. + // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + // types. + // + // Supported formats: + // + // * `UNKNOWN_DEVICE_TYPE` + // + // * `DESKTOP` + // + // * `MOBILE` + // + // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + string device_type = 4; + + // Determines which dataset to use for fetching completion. "user-data" will + // use the imported dataset through + // [CompletionService.ImportCompletionData][google.cloud.retail.v2alpha.CompletionService.ImportCompletionData]. + // "cloud-retail" will use the dataset generated by cloud retail based on user + // events. If leave empty, it will use the "user-data". + // + // Current supported values: + // + // * user-data + // + // * cloud-retail + // This option requires additional allowlisting. Before using cloud-retail, + // contact Cloud Retail support team first. + string dataset = 6; + + // Completion max suggestions. If left unset or set to 0, then will fallback + // to the configured value + // [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions]. + // + // The maximum allowed max suggestions is 20. If it is set higher, it will be + // capped by 20. + int32 max_suggestions = 5; +} + +// Response of the auto-complete query. +message CompleteQueryResponse { + // Resource that represents completion results. + message CompletionResult { + // The suggestion for the query. + string suggestion = 1; + + // Custom attributes for the suggestion term. + // * For "user-data", the attributes are additional custom attributes + // ingested through BigQuery. + // * For "cloud-retail", the attributes are product attributes generated + // by Cloud Retail. + map attributes = 2; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Results of the matching suggestions. The result list is ordered and the + // first result is top suggestion. + repeated CompletionResult completion_results = 1; + + // A unique complete token. This should be included in the + // [UserEvent.completion_detail][google.cloud.retail.v2alpha.UserEvent.completion_detail] + // for search events resulting from this completion, which enables accurate + // attribution of complete model performance. + string attribution_token = 2; + + // Matched recent searches of this user. The maximum number of recent searches + // is 10. This field is a restricted feature. Contact Retail Search support + // team if you are interested in enabling it. + // + // This feature is only available when + // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2alpha.CompleteQueryRequest.visitor_id] + // field is set and [UserEvent][google.cloud.retail.v2alpha.UserEvent] is + // imported. The recent searches satisfy the follow rules: + // * They are ordered from latest to oldest. + // * They are matched with + // [CompleteQueryRequest.query][google.cloud.retail.v2alpha.CompleteQueryRequest.query] + // case insensitively. + // * They are transformed to lower cases. + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto new file mode 100644 index 00000000..4d85015e --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto @@ -0,0 +1,92 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configures dynamic serving time metadata that is used to pre and post +// process search/recommendation model results. +message Control { + option (google.api.resource) = { + type: "retail.googleapis.com/Control" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }; + + // The behavior/type of the control + // + // A behavior/type must be specified on creation. Type cannot be changed once + // specified (e.g. A Rule control will always be a Rule control.). An + // INVALID_ARGUMENT will be returned if either condition is violated. + oneof control { + // A facet specification to perform faceted search. + SearchRequest.FacetSpec facet_spec = 3; + + // A rule control - a condition-action pair. + // Enacts a set action when the condition is triggered. + // For example: Boost "gShoe" when query full matches "Running Shoes". + Rule rule = 4; + } + + // Immutable. Fully qualified name + // projects/*/locations/global/catalogs/*/controls/* + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable control display name. Used in Retail UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is thrown. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Output only. List of serving configuration ids that that are associated + // with this control. Note the association is managed via the ServingConfig, + // this is an output only denormalizeed view. Assumed to be in the same + // catalog. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the serving config is used + // for. Currently we support setting only one type of solution at creation + // time. + // + // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. + // If no solution type is provided at creation time, will default to + // SOLUTION_TYPE_SEARCH. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Specifies the use case for the control. + // Affects what condition fields can be set. + // Only settable by search controls. + // Will default to SEARCH_SOLUTION_USE_CASE_SEARCH if not specified. + // Currently only allow one search_solution_use_case per control. + repeated SearchSolutionUseCase search_solution_use_case = 7 + [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto new file mode 100644 index 00000000..6372aca6 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto @@ -0,0 +1,184 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/control.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for modifying Control. +service ControlService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a Control. + // + // If the [Control][google.cloud.retail.v2alpha.Control] to create already + // exists, an ALREADY_EXISTS error is returned. + rpc CreateControl(CreateControlRequest) returns (Control) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" + body: "control" + }; + option (google.api.method_signature) = "parent,control,control_id"; + } + + // Deletes a Control. + // + // If the [Control][google.cloud.retail.v2alpha.Control] to delete does not + // exist, a NOT_FOUND error is returned. + rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Control. + // + // [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different + // oneof field, if so an INVALID_ARGUMENT is returned. If the + // [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a + // NOT_FOUND error is returned. + rpc UpdateControl(UpdateControlRequest) returns (Control) { + option (google.api.http) = { + patch: "/v2alpha/{control.name=projects/*/locations/*/catalogs/*/controls/*}" + body: "control" + }; + option (google.api.method_signature) = "control,update_mask"; + } + + // Gets a Control. + rpc GetControl(GetControlRequest) returns (Control) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all Controls linked to this catalog. + rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request for CreateControl method. +message CreateControlRequest { + // Required. Full resource name of parent catalog. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The Control to create. + Control control = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the Control, which will become the final + // component of the Control's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string control_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateControl method. +message UpdateControlRequest { + // Required. The Control to update. + Control control = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Control][google.cloud.retail.v2alpha.Control] to update. The following are + // NOT supported: + // + // * [Control.name][google.cloud.retail.v2alpha.Control.name] + // + // If not set or empty, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteControl method. +message DeleteControlRequest { + // Required. The resource name of the Control to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for GetControl method. +message GetControlRequest { + // Required. The resource name of the Control to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for ListControls method. +message ListControlsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 50. Max allowed value is 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListControls` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2alpha.ListControlsRequest.filter] is unset. + // * List controls that are used in a single ServingConfig: + // 'serving_config = "boosted_home_page_cvr"' + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListControls method. +message ListControlsResponse { + // All the Controls for a given catalog. + repeated Control controls = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto new file mode 100644 index 00000000..f29c7f9a --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto @@ -0,0 +1,77 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ExportConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configuration of destination for Export related errors. +message ExportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage path for import errors. This must be an empty, + // existing Cloud Storage bucket. Export errors will be written to a file in + // this bucket, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Metadata related to the progress of the Export operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ExportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Response of the ExportProductsRequest. If the long running +// operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ExportErrorsConfig errors_config = 2; +} + +// Response of the ExportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ExportErrorsConfig errors_config = 2; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto new file mode 100644 index 00000000..a1fcf240 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto @@ -0,0 +1,397 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/cloud/retail/v2alpha/user_event.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Google Cloud Storage location for input content. +// format. +message GcsSource { + // Required. Google Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. A request can + // contain at most 100 files, and each file can be up to 2 GB. See + // [Importing product + // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) + // for the expected file format and setup instructions. + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. + // * `user_event_ga360`: Using + // https://support.google.com/analytics/answer/3437719. + // + // Supported values for control imports: + // + // * 'control' (default): One JSON + // [Control][google.cloud.retail.v2alpha.Control] per line. + // + // Supported values for catalog attribute imports: + // + // * 'catalog_attribute' (default): One CSV + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + google.type.Date partition_date = 6; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 5; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 3; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. + // * `user_event_ga360`: + // The schema is available here: + // https://support.google.com/analytics/answer/3437719. + // * `user_event_ga4`: This feature is in private preview. Please contact the + // support team for importing Google Analytics 4 events. + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for auto-completion imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + string data_schema = 4; +} + +// The inline source for the input config for ImportProducts method. +message ProductInlineSource { + // Required. A list of products to update/create. Each product must have a + // valid [Product.id][google.cloud.retail.v2alpha.Product.id]. Recommended max + // of 100 items. + repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The inline source for the input config for ImportUserEvents method. +message UserEventInlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configuration of destination for Import related errors. +message ImportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors will be written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for Import methods. +message ImportProductsRequest { + // Indicates how imported products are reconciled with the existing products + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new products or updates existing products. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire product dataset. Existing + // products may be deleted if they are not present in the source location. + // + // Can only be set while using + // [BigQuerySource][google.cloud.retail.v2alpha.BigQuerySource]. And the + // BigQuery dataset must be created in the data location "us (multiple + // regions in United States)", otherwise a PERMISSION_DENIED error is + // thrown. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + FULL = 2; + } + + // Required. + // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + // + // If no updateMask is specified, requires products.create permission. + // If updateMask is specified, requires products.update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Deprecated. This field has no effect. + string request_id = 6 [deprecated = true]; + + // Required. The desired input location of the data. + ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. + ImportErrorsConfig errors_config = 3; + + // Indicates which fields in the provided imported 'products' to update. If + // not set, will by default update all fields. + google.protobuf.FieldMask update_mask = 4; + + // The mode of reconciliation between existing products and the products to be + // imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 5; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + string notification_pubsub_topic = 7; +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // Required. `projects/1234/locations/global/catalogs/default_catalog` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + UserEventInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorsConfig errors_config = 3; +} + +// Request message for ImportCompletionData methods. +message ImportCompletionDataRequest { + // Required. The catalog which the suggestions dataset belongs to. + // + // Format: `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + CompletionDataInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 3; +} + +// The input config source for products. +message ProductInputConfig { + // Required. The source of the input. + oneof source { + // The Inline source for the input content for products. + ProductInlineSource product_inline_source = 1; + + // Google Cloud Storage location for the input content. + GcsSource gcs_source = 2; + + // BigQuery input source. + BigQuerySource big_query_source = 3; + } +} + +// The input config source for user events. +message UserEventInputConfig { + // The source of the input. + oneof source { + // Required. The Inline source for the input content for UserEvents. + UserEventInlineSource user_event_inline_source = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Google Cloud Storage location for the input content. + GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource big_query_source = 3 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// The input config source for completion data. +message CompletionDataInputConfig { + // The source of the input. + // + // Supported + // [BigQuerySource.data_schema][google.cloud.retail.v2alpha.BigQuerySource.data_schema] + // values for suggestions imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + oneof source { + // Required. BigQuery input source. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + BigQuerySource big_query_source = 1 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// Metadata related to the progress of the Import operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ImportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; + + // Deprecated. This field is never set. + string request_id = 5 [deprecated = true]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; +} + +// Response of the +// [ImportProductsRequest][google.cloud.retail.v2alpha.ImportProductsRequest]. +// If the long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorsConfig errors_config = 2; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorsConfig errors_config = 2; + + // Aggregated statistics of user event import status. + UserEventImportSummary import_summary = 3; +} + +// A summary of import result. The UserEventImportSummary summarizes +// the import status for user events. +message UserEventImportSummary { + // Count of user events imported with complete existing catalog information. + int64 joined_events_count = 1; + + // Count of user events imported, but with catalog information not found + // in the imported catalog. + int64 unjoined_events_count = 2; +} + +// Response of the +// [ImportCompletionDataRequest][google.cloud.retail.v2alpha.ImportCompletionDataRequest]. +// If the long running operation is done, this message is returned by the +// google.longrunning.Operations.response field if the operation is successful. +message ImportCompletionDataResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto new file mode 100644 index 00000000..5b89bceb --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto @@ -0,0 +1,194 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2alpha/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "PredictionServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for making recommendation prediction. +service PredictionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation prediction. + rpc Predict(PredictRequest) returns (PredictResponse) { + option (google.api.http) = { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" + body: "*" + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} + // The ID of the Recommendations AI placement. Before you can request + // predictions from your model, you must create at least one placement for it. + // For more information, see [Managing + // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + // + // The full list of available placements can be seen at + // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the predict request. Note that this user event detail + // won't be ingested to userEvent logs. Thus, a separate userEvent write + // request is required for event logging. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return per page. Set this property + // to the number of prediction results needed. If zero, the service will + // choose a reasonable default. The maximum allowed value is 100. Values + // above 100 will be coerced to 100. + int32 page_size = 3; + + // The previous PredictResponse.next_page_token. + string page_token = 4; + + // Filter for restricting prediction results with a length limit of 5,000 + // characters. Accepts values for tags and the `filterOutOfStockItems` flag. + // + // * Tag expressions. Restricts predictions to products that match all of the + // specified tags. Boolean operators `OR` and `NOT` are supported if the + // expression is enclosed in parentheses, and must be separated from the + // tag values by a space. `-"tagA"` is also supported and is equivalent to + // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + // with a size limit of 1,000 characters. + // + // Note: "Recently viewed" models don't support tag filtering at the + // moment. + // + // * filterOutOfStockItems. Restricts predictions to products that do not + // have a + // stockState value of OUT_OF_STOCK. + // + // Examples: + // + // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + // * filterOutOfStockItems tag=(-"promotional") + // * filterOutOfStockItems + // + // If your filter blocks all prediction results, the API will return generic + // (unfiltered) popular products. If you only want results strictly matching + // the filters, set `strictFiltering` to True in `PredictRequest.params` to + // receive empty results instead. + // Note that the API will never return items with storageStatus of "EXPIRED" + // or "DELETED" regardless of filter choices. + string filter = 5; + + // Use validate only mode for this prediction query. If set to true, a + // dummy model will be used that returns arbitrary products. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 6; + + // Additional domain specific parameters for the predictions. + // + // Allowed values: + // + // * `returnProduct`: Boolean. If set to true, the associated product + // object will be returned in the `results.metadata` field in the + // prediction response. + // * `returnScore`: Boolean. If set to true, the prediction 'score' + // corresponding to each returned product will be set in the + // `results.metadata` field in the prediction response. The given + // 'score' indicates the probability of an product being clicked/purchased + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular products instead of empty if + // your filter blocks all prediction results. + // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-price-reranking', 'low-price-reranking', + // 'medium-price-reranking', 'high-price-reranking'}. This gives + // request-level control and adjusts prediction results based on product + // price. + // * `diversityLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-diversity', 'low-diversity', + // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + // request-level control and adjusts prediction results based on product + // category. + map params = 7; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters, and cannot be empty. Values can be empty, and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 8; +} + +// Response message for predict method. +message PredictResponse { + // PredictionResult represents the recommendation prediction results. + message PredictionResult { + // ID of the recommended product + string id = 1; + + // Additional product metadata / annotations. + // + // Possible values: + // + // * `product`: JSON representation of the product. Will be set if + // `returnProduct` is set to true in `PredictRequest.params`. + // * `score`: Prediction score in double value. Will be set if + // `returnScore` is set to true in `PredictRequest.params`. + map metadata = 2; + } + + // A list of recommended products. The order represents the ranking (from the + // most relevant product to the least). + repeated PredictionResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this + // recommendation, which enables accurate attribution of recommendation model + // performance. + string attribution_token = 2; + + // IDs of products in the request that were missing from the inventory. + repeated string missing_ids = 3; + + // True if the validateOnly property was set in the request. + bool validate_only = 4; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto new file mode 100644 index 00000000..cbadc568 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto @@ -0,0 +1,567 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/promotion.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" +}; + +// Product captures all metadata information of items to be recommended or +// searched. +message Product { + option (google.api.resource) = { + type: "retail.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }; + + // The type of this product. + enum Type { + // Default value. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] + // if unset. + TYPE_UNSPECIFIED = 0; + + // The primary type. + // + // As the primary unit for predicting, indexing and search serving, a + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] is grouped with multiple + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s. + PRIMARY = 1; + + // The variant type. + // + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s usually share some common + // attributes on the same + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s, but they have variant + // attributes like different colors, sizes and prices, etc. + VARIANT = 2; + + // The collection type. Collection products are bundled + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s or + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s that are sold together, + // such as a jewelry set with necklaces, earrings and rings, etc. + COLLECTION = 3; + } + + // Product availability. If this field is unspecified, the product is + // assumed to be in stock. + enum Availability { + // Default product availability. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK] + // if unset. + AVAILABILITY_UNSPECIFIED = 0; + + // Product in stock. + IN_STOCK = 1; + + // Product out of stock. + OUT_OF_STOCK = 2; + + // Product that is in pre-order state. + PREORDER = 3; + + // Product that is back-ordered (i.e. temporarily out of stock). + BACKORDER = 4; + } + + oneof expiration { + // The timestamp when this product becomes unavailable for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // If it is set, the [Product][google.cloud.retail.v2alpha.Product] is not + // available for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // after [expire_time][google.cloud.retail.v2alpha.Product.expire_time]. + // However, the product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] must be + // later than + // [available_time][google.cloud.retail.v2alpha.Product.available_time] and + // [publish_time][google.cloud.retail.v2alpha.Product.publish_time], + // otherwise an INVALID_ARGUMENT error is thrown. + // + // Corresponding properties: Google Merchant Center property + // [expiration_date](https://support.google.com/merchants/answer/6324499). + google.protobuf.Timestamp expire_time = 16; + + // Input only. The TTL (time to live) of the product. + // + // If it is set, it must be a non-negative value, and + // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is set as + // current timestamp plus [ttl][google.cloud.retail.v2alpha.Product.ttl]. + // The derived + // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is + // returned in the output and [ttl][google.cloud.retail.v2alpha.Product.ttl] + // is left blank when retrieving the + // [Product][google.cloud.retail.v2alpha.Product]. + // + // If it is set, the product is not available for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // after current timestamp plus + // [ttl][google.cloud.retail.v2alpha.Product.ttl]. However, the product can + // still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + google.protobuf.Duration ttl = 17 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Immutable. Full resource name of the product, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. [Product][google.cloud.retail.v2alpha.Product] identifier, which + // is the final component of [name][google.cloud.retail.v2alpha.Product.name]. + // For example, this field is "id_1", if + // [name][google.cloud.retail.v2alpha.Product.name] is + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [id](https://support.google.com/merchants/answer/6324405). Schema.org + // property [Product.sku](https://schema.org/sku). + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The type of the product. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] + // if unset. + Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Variant group identifier. Must be an + // [id][google.cloud.retail.v2alpha.Product.id], with the same parent branch + // with this product. Otherwise, an error is thrown. + // + // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s, this field can only be + // empty or set to the same value as + // [id][google.cloud.retail.v2alpha.Product.id]. + // + // For VARIANT [Product][google.cloud.retail.v2alpha.Product]s, this field + // cannot be empty. A maximum of 2,000 products are allowed to share the same + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [item_group_id](https://support.google.com/merchants/answer/6324507). + // Schema.org property + // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). + string primary_product_id = 4; + + // The [id][google.cloud.retail.v2alpha.Product.id] of the collection members + // when [type][google.cloud.retail.v2alpha.Product.type] is + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]. + // + // Non-existent product ids are allowed. + // The [type][google.cloud.retail.v2alpha.Product.type] of the members must be + // either [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] or + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] otherwise + // and INVALID_ARGUMENT error is thrown. Should not set it for other types. A + // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is + // return. + repeated string collection_member_ids = 5; + + // The Global Trade Item Number (GTIN) of the product. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Corresponding properties: Google Merchant Center property + // [gtin](https://support.google.com/merchants/answer/6324461). + // Schema.org property + // [Product.isbn](https://schema.org/isbn), + // [Product.gtin8](https://schema.org/gtin8), + // [Product.gtin12](https://schema.org/gtin12), + // [Product.gtin13](https://schema.org/gtin13), or + // [Product.gtin14](https://schema.org/gtin14). + // + // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. + string gtin = 6; + + // Product categories. This field is repeated for supporting one product + // belonging to several parallel categories. Strongly recommended using the + // full path for better search / recommendation quality. + // + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // For example, if a shoes product belongs to both + // ["Shoes & Accessories" -> "Shoes"] and + // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be + // represented as: + // + // "categories": [ + // "Shoes & Accessories > Shoes", + // "Sports & Fitness > Athletic Clothing > Shoes" + // ] + // + // Must be set for + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] otherwise an + // INVALID_ARGUMENT error is returned. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [google_product_category][mc_google_product_category]. Schema.org property + // [Product.category] (https://schema.org/category). + // + // [mc_google_product_category]: + // https://support.google.com/merchants/answer/6324436 + repeated string categories = 7; + + // Required. Product title. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [title](https://support.google.com/merchants/answer/6324415). Schema.org + // property [Product.name](https://schema.org/name). + string title = 8 [(google.api.field_behavior) = REQUIRED]; + + // The brands of the product. + // + // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded + // string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [brand](https://support.google.com/merchants/answer/6324351). Schema.org + // property [Product.brand](https://schema.org/brand). + repeated string brands = 9; + + // Product description. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [description](https://support.google.com/merchants/answer/6324468). + // Schema.org property [Product.description](https://schema.org/description). + string description = 10; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // + // For product prediction, this field is ignored and the model automatically + // detects the text language. The + // [Product][google.cloud.retail.v2alpha.Product] can include text in + // different languages, but duplicating + // [Product][google.cloud.retail.v2alpha.Product]s to provide text in multiple + // languages can result in degraded model performance. + // + // For product search this field is in use. It defaults to "en-US" if unset. + string language_code = 11; + + // Highly encouraged. Extra product attributes to be included. For example, + // for products, this could include the store name, vendor, style, color, etc. + // These are very strong signals for recommendation model, thus we highly + // recommend providing the attributes here. + // + // Features that can take on one of a limited number of possible values. Two + // types of features can be set are: + // + // Textual features. some examples would be the brand/maker of a product, or + // country of a customer. Numerical features. Some examples would be the + // height/weight of a product, or age of a customer. + // + // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, + // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} + // }`. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * Max entries count: 200. + // * The key must be a UTF-8 encoded string with a length limit of 128 + // characters. + // * For indexable attribute, the key must match the pattern: + // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or + // `KEY_1_LIKE_THIS`. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a non-empty UTF-8 encoded string with a + // length limit of 256 characters. + // * For number attributes, at most 400 values are allowed. + map attributes = 12; + + // Custom tags associated with the product. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. This value must be a UTF-8 + // encoded string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This tag can be used for filtering recommendation results by passing the + // tag as part of the + // [PredictRequest.filter][google.cloud.retail.v2alpha.PredictRequest.filter]. + // + // Corresponding properties: Google Merchant Center property + // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). + repeated string tags = 13; + + // Product price and cost information. + // + // Corresponding properties: Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 14; + + // The rating of this product. + Rating rating = 15; + + // The timestamp when this [Product][google.cloud.retail.v2alpha.Product] + // becomes available for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + google.protobuf.Timestamp available_time = 18; + + // The online availability of the + // [Product][google.cloud.retail.v2alpha.Product]. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK]. + // + // Corresponding properties: Google Merchant Center property + // [availability](https://support.google.com/merchants/answer/6324448). + // Schema.org property [Offer.availability](https://schema.org/availability). + Availability availability = 19; + + // The available quantity of the item. + google.protobuf.Int32Value available_quantity = 20; + + // Fulfillment information, such as the store IDs for in-store pickup or + // region IDs for different shipping methods. + // + // All the elements must have distinct + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated FulfillmentInfo fulfillment_info = 21; + + // Canonical URL directly linking to the product detail page. + // + // It is strongly recommended to provide a valid uri for the product, + // otherwise the service performance could be significantly degraded. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [link](https://support.google.com/merchants/answer/6324416). Schema.org + // property [Offer.url](https://schema.org/url). + string uri = 22; + + // Product images for the product. We highly recommend putting the main + // image first. + // + // A maximum of 300 images are allowed. + // + // Corresponding properties: Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + repeated Image images = 23; + + // The target group associated with a given audience (e.g. male, veterans, + // car owners, musicians, etc.) of the product. + Audience audience = 24; + + // The color of the product. + // + // Corresponding properties: Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + ColorInfo color_info = 25; + + // The size of the product. To represent different size systems or size types, + // consider using this format: [[[size_system:]size_type:]size_value]. + // + // For example, in "US:MENS:M", "US" represents size system; "MENS" represents + // size type; "M" represents size value. In "GIRLS:27", size system is empty; + // "GIRLS" represents size type; "27" represents size value. In "32 inches", + // both size system and size type are empty, while size value is "32 inches". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [size](https://support.google.com/merchants/answer/6324492), + // [size_type](https://support.google.com/merchants/answer/6324497), and + // [size_system](https://support.google.com/merchants/answer/6324502). + // Schema.org property [Product.size](https://schema.org/size). + repeated string sizes = 26; + + // The material of the product. For example, "leather", "wooden". + // + // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 200 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [material](https://support.google.com/merchants/answer/6324410). Schema.org + // property [Product.material](https://schema.org/material). + repeated string materials = 27; + + // The pattern or graphic print of the product. For example, "striped", "polka + // dot", "paisley". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org + // property [Product.pattern](https://schema.org/pattern). + repeated string patterns = 28; + + // The condition of the product. Strongly encouraged to use the standard + // values: "new", "refurbished", "used". + // + // A maximum of 1 value is allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [condition](https://support.google.com/merchants/answer/6324469). + // Schema.org property + // [Offer.itemCondition](https://schema.org/itemCondition). + repeated string conditions = 29; + + // The promotions applied to the product. A maximum of 10 values are allowed + // per [Product][google.cloud.retail.v2alpha.Product]. Only + // [Promotion.promotion_id][google.cloud.retail.v2alpha.Promotion.promotion_id] + // will be used, other fields will be ignored if set. + repeated Promotion promotions = 34; + + // The timestamp when the product is published by the retailer for the first + // time, which indicates the freshness of the products. Note that this field + // is different from + // [available_time][google.cloud.retail.v2alpha.Product.available_time], given + // it purely describes product freshness regardless of when it is available on + // search and recommendation. + google.protobuf.Timestamp publish_time = 33; + + // Indicates which fields in the + // [Product][google.cloud.retail.v2alpha.Product]s are returned in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse]. + // + // Supported fields for all [type][google.cloud.retail.v2alpha.Product.type]s: + // + // * [audience][google.cloud.retail.v2alpha.Product.audience] + // * [availability][google.cloud.retail.v2alpha.Product.availability] + // * [brands][google.cloud.retail.v2alpha.Product.brands] + // * [color_info][google.cloud.retail.v2alpha.Product.color_info] + // * [conditions][google.cloud.retail.v2alpha.Product.conditions] + // * [gtin][google.cloud.retail.v2alpha.Product.gtin] + // * [materials][google.cloud.retail.v2alpha.Product.materials] + // * [name][google.cloud.retail.v2alpha.Product.name] + // * [patterns][google.cloud.retail.v2alpha.Product.patterns] + // * [price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [rating][google.cloud.retail.v2alpha.Product.rating] + // * [sizes][google.cloud.retail.v2alpha.Product.sizes] + // * [title][google.cloud.retail.v2alpha.Product.title] + // * [uri][google.cloud.retail.v2alpha.Product.uri] + // + // Supported fields only for + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]: + // + // * [categories][google.cloud.retail.v2alpha.Product.categories] + // * [description][google.cloud.retail.v2alpha.Product.description] + // * [images][google.cloud.retail.v2alpha.Product.images] + // + // Supported fields only for + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]: + // + // * Only the first image in + // [images][google.cloud.retail.v2alpha.Product.images] + // + // To mark [attributes][google.cloud.retail.v2alpha.Product.attributes] as + // retrievable, include paths of the form "attributes.key" where "key" is the + // key of a custom attribute, as specified in + // [attributes][google.cloud.retail.v2alpha.Product.attributes]. + // + // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], the + // following fields are always returned in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] by default: + // + // * [name][google.cloud.retail.v2alpha.Product.name] + // + // For [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT], the + // following fields are always returned in by default: + // + // * [name][google.cloud.retail.v2alpha.Product.name] + // * [color_info][google.cloud.retail.v2alpha.Product.color_info] + // + // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] may increase + // response payload size and serving latency. + google.protobuf.FieldMask retrievable_fields = 30; + + // Output only. Product variants grouped together on primary product which + // share similar product attributes. It's automatically grouped by + // [primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] + // for all the product variants. Only populated for + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. + // Do not set this field in API requests. + repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto new file mode 100644 index 00000000..7bced3fb --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto @@ -0,0 +1,882 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/cloud/retail/v2alpha/purge_config.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for ingesting [Product][google.cloud.retail.v2alpha.Product] +// information of the customer's website. +service ProductService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Product][google.cloud.retail.v2alpha.Product]. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Gets a [Product][google.cloud.retail.v2alpha.Product]. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Product][google.cloud.retail.v2alpha.Product]s. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a [Product][google.cloud.retail.v2alpha.Product]. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v2alpha/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Deletes a [Product][google.cloud.retail.v2alpha.Product]. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Permanently deletes all selected + // [Product][google.cloud.retail.v2alpha.Product]s under a branch. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed offline. Depending on the number of + // [Product][google.cloud.retail.v2alpha.Product]s, this operation could take + // hours to complete. Before the operation completes, some + // [Product][google.cloud.retail.v2alpha.Product]s may still be returned by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, + // this operation could take hours to complete. To get a sample of + // [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set + // [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] + // to false. + rpc PurgeProducts(PurgeProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.PurgeProductsResponse" + metadata_type: "google.cloud.retail.v2alpha.PurgeProductsMetadata" + }; + } + + // Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. + // + // Request processing may be synchronous. No partial updating is supported. + // Non-existing items are created. + // + // Note that it is possible for a subset of the + // [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated. + rpc ImportProducts(ImportProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.ImportProductsResponse" + metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" + }; + } + + // Updates inventory information for a + // [Product][google.cloud.retail.v2alpha.Product] while respecting the last + // update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, updates are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // When inventory is updated with + // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], + // the specified inventory field value(s) will overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update time for the specified inventory fields will be overwritten to the + // time of the + // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // or + // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // request. + // + // If no inventory fields are set in + // [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], + // then any pre-existing inventory information for this product will be used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], + // then any existing inventory information will be preserved. + // + // Pre-existing inventory information can only be updated with + // [SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], + // [AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], + // and + // [RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" + body: "*" + }; + option (google.api.method_signature) = "inventory,set_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.SetInventoryResponse" + metadata_type: "google.cloud.retail.v2alpha.SetInventoryMetadata" + }; + } + + // Incrementally adds place IDs to + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the added place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata" + }; + } + + // Incrementally removes place IDs from a + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the removed place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata" + }; + } + + // Updates local inventory information for a + // [Product][google.cloud.retail.v2alpha.Product] at a list of places, while + // respecting the last update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // inventory information. If the request is valid, the update will be enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddLocalInventories(AddLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.AddLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2alpha.AddLocalInventoriesMetadata" + }; + } + + // Remove local inventory information for a + // [Product][google.cloud.retail.v2alpha.Product] at a list of places at a + // removal timestamp. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, removals are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata" + }; + } +} + +// Request message for [CreateProduct][] method. +message CreateProductRequest { + // Required. The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The [Product][google.cloud.retail.v2alpha.Product] to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Product][google.cloud.retail.v2alpha.Product], which will become the final + // component of the [Product.name][google.cloud.retail.v2alpha.Product.name]. + // + // If the caller does not have permission to create the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // This field must be unique among all + // [Product][google.cloud.retail.v2alpha.Product]s with the same + // [parent][google.cloud.retail.v2alpha.CreateProductRequest.parent]. + // Otherwise, an ALREADY_EXISTS error is returned. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string product_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [GetProduct][] method. +message GetProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the requested [Product][google.cloud.retail.v2alpha.Product] does not + // exist, a NOT_FOUND error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for [UpdateProduct][] method. +message UpdateProductRequest { + // Required. The product to update/create. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to update does not + // exist and + // [allow_missing][google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing] + // is not set, a NOT_FOUND error is returned. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Product][google.cloud.retail.v2alpha.Product] to update. The immutable and + // output only fields are NOT supported. If not set, all supported fields (the + // fields that are neither immutable nor output only) are updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, a new [Product][google.cloud.retail.v2alpha.Product] will be + // created. In this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for [DeleteProduct][] method. +message DeleteProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to delete the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to delete does not + // exist, a NOT_FOUND error is returned. + // + // The [Product][google.cloud.retail.v2alpha.Product] to delete can neither be + // a + // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2alpha.Product] member nor a + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] with more than one + // [variants][google.cloud.retail.v2alpha.Product.Type.VARIANT]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // All inventory information for the named + // [Product][google.cloud.retail.v2alpha.Product] will be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] +// method. +message ListProductsRequest { + // Required. The parent branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use + // `default_branch` as the branch ID, to list products under the default + // branch. + // + // If the caller does not have permission to list + // [Product][google.cloud.retail.v2alpha.Product]s under this branch, + // regardless of whether or not this branch exists, a PERMISSION_DENIED error + // is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to + // return. If unspecified, defaults to 100. The maximum allowed value is 1000. + // Values above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT error is returned. + int32 page_size = 2; + + // A page token + // [ListProductsResponse.next_page_token][google.cloud.retail.v2alpha.ListProductsResponse.next_page_token], + // received from a previous + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; + + // A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2alpha.ListProductsRequest.filter] is unset. + // * List + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s sharing the same + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]. For example: + // `primary_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2alpha.Product]s bundled in a + // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2alpha.Product]. + // For example: + // `collection_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2alpha.Product]s with a partibular + // type. For example: + // `type = "PRIMARY"` + // `type = "VARIANT"` + // `type = "COLLECTION"` + // + // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + // + // If the specified + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] or + // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2alpha.Product] does not exist, a NOT_FOUND + // error is returned. + string filter = 4; + + // The fields of [Product][google.cloud.retail.v2alpha.Product] to return in + // the responses. If not set or empty, the following fields are returned: + // + // * [Product.name][google.cloud.retail.v2alpha.Product.name] + // * [Product.id][google.cloud.retail.v2alpha.Product.id] + // * [Product.title][google.cloud.retail.v2alpha.Product.title] + // * [Product.uri][google.cloud.retail.v2alpha.Product.uri] + // * [Product.images][google.cloud.retail.v2alpha.Product.images] + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [Product.brands][google.cloud.retail.v2alpha.Product.brands] + // + // If "*" is provided, all fields are returned. + // [Product.name][google.cloud.retail.v2alpha.Product.name] is always returned + // no matter what mask is set. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask read_mask = 5; + + // If true and + // [page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] is + // empty, + // [ListProductsResponse.total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] + // is set to the total count of matched items irrespective of pagination. + // + // Notice that setting this field to true affects the performance. + bool require_total_size = 6; +} + +// Response message for +// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] +// method. +message ListProductsResponse { + // The [Product][google.cloud.retail.v2alpha.Product]s. + repeated Product products = 1; + + // A token that can be sent as + // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; + + // The total count of matched [Product][google.cloud.retail.v2alpha.Product]s + // irrespective of pagination. The total number of + // [Product][google.cloud.retail.v2alpha.Product]s returned by pagination may + // be less than the + // [total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] + // that matches. + // + // This field is ignored if + // [ListProductsRequest.require_total_size][google.cloud.retail.v2alpha.ListProductsRequest.require_total_size] + // is not set or + // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] + // is not empty. + int32 total_size = 3; +} + +// Request message for [SetInventory][] method. +message SetInventoryRequest { + // Required. The inventory information to update. The allowable fields to + // update are: + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] + // The updated inventory fields must be specified in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask]. + // + // If [SetInventoryRequest.inventory.name][] is empty or invalid, an + // INVALID_ARGUMENT error is returned. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2alpha.Product] named in + // [Product.name][google.cloud.retail.v2alpha.Product.name], regardless of + // whether or not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to update does not + // have existing inventory information, the provided inventory information + // will be inserted. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to update has + // existing inventory information, the provided inventory information will be + // merged while respecting the last update time for each inventory field, + // using the provided or default value for + // [SetInventoryRequest.set_time][google.cloud.retail.v2alpha.SetInventoryRequest.set_time]. + // + // The caller can replace place IDs for a subset of fulfillment types in the + // following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types and corresponding place IDs + // to update in [SetInventoryRequest.inventory.fulfillment_info][] + // + // The caller can clear all place IDs from a subset of fulfillment types in + // the following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types to clear in + // [SetInventoryRequest.inventory.fulfillment_info][] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] + // + // The last update time is recorded for the following inventory fields: + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] + // + // If a full overwrite of inventory information while ignoring timestamps is + // needed, [UpdateProduct][] should be invoked instead. + Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided + // [Product][google.cloud.retail.v2alpha.Product] to update. + // + // At least one field must be provided. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask set_mask = 2; + + // The time when the request is issued, used to prevent + // out-of-order updates on inventory fields with the last update time + // recorded. If not provided, the internal system time will be used. + google.protobuf.Timestamp set_time = 3; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] with + // name [Product.name][google.cloud.retail.v2alpha.Product.name] is not found, + // the inventory update will still be processed and retained for at most 1 day + // until the [Product][google.cloud.retail.v2alpha.Product] is created. If set + // to false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 4; +} + +// Metadata related to the progress of the SetInventory operation. +// Currently empty because there is no meaningful metadata populated from the +// [SetInventory][] method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the [SetInventory][] +// method. +message SetInventoryResponse {} + +// Request message for [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type], such + // as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery" to be added for this + // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type]. + // Duplicate IDs will be automatically ignored. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // If the total number of place IDs exceeds 2000 for this + // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type] after + // adding, then the update will be rejected. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the AddFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesMetadata {} + +// Response of the AddFulfillmentPlacesRequest. Currently empty because +// there is no meaningful response populated from the [AddFulfillmentPlaces][] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for [AddLocalInventories][] method. +message AddLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of inventory information at difference places. Each place + // is identified by its place ID. At most 3000 inventories are allowed per + // request. + repeated LocalInventory local_inventories = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided list of + // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory] to update. The + // field is updated to the provided value. + // + // If a field is set while the place does not have a previous local inventory, + // the local inventory at that store is created. + // + // If a field is set while the value of that field is not provided, the + // original field value, if it exists, is deleted. + // + // If the mask is not set or set with empty paths, all inventory fields will + // be updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask add_mask = 4; + + // The time when the inventory updates are issued. Used to prevent + // out-of-order updates on local inventory fields. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the local inventory will still be processed and retained for at + // most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 6; +} + +// Metadata related to the progress of the AddLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddLocalInventories][] method. +message AddLocalInventoriesMetadata {} + +// Response of the [AddLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [AddLocalInventories][] +// method. +message AddLocalInventoriesResponse {} + +// Request message for [RemoveLocalInventories][] method. +message RemoveLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of place IDs to have their inventory deleted. + // At most 3000 place IDs are allowed per request. + repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; + + // The time when the inventory deletions are issued. Used to prevent + // out-of-order updates and deletions on local inventory fields. If not + // provided, the internal system time will be used. + google.protobuf.Timestamp remove_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the local inventory removal request will still be processed and + // retained for at most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 3; +} + +// Metadata related to the progress of the RemoveLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveLocalInventories][] method. +message RemoveLocalInventoriesMetadata {} + +// Response of the [RemoveLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [RemoveLocalInventories][] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type], + // such as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery", to be removed for this + // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type]. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp remove_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the RemoveFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the [RemoveFulfillmentPlaces][] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto new file mode 100644 index 00000000..879449a4 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto @@ -0,0 +1,40 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "PromotionProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Promotion information. +message Promotion { + // ID of the promotion. For example, "free gift". + // + // The value must be a UTF-8 encoded string with a length limit of 128 + // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, + // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Google Merchant Center property + // [promotion](https://support.google.com/merchants/answer/7050148). + string promotion_id = 1; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto new file mode 100644 index 00000000..6b929f26 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto @@ -0,0 +1,171 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Metadata related to the progress of the Purge operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeMetadata {} + +// Metadata related to the progress of the PurgeProducts operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeProductsMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were deleted successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; +} + +// Request message for PurgeProducts method. +message PurgeProductsRequest { + // Required. The resource name of the branch under which the products are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The filter string to specify the products to be deleted with a + // length limit of 5,000 characters. + // + // Empty string filter is not allowed. "*" implies delete all items in a + // branch. + // + // The eligible fields for filtering are: + // + // * `availability`: Double quoted + // [Product.availability][google.cloud.retail.v2alpha.Product.availability] + // string. + // * `create_time` : in ISO 8601 "zulu" format. + // + // Supported syntax: + // + // * Comparators (">", "<", ">=", "<=", "="). + // Examples: + // * create_time <= "2015-02-13T17:05:46Z" + // * availability = "IN_STOCK" + // + // * Conjunctions ("AND") + // Examples: + // * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" + // + // * Disjunctions ("OR") + // Examples: + // * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" + // + // * Can support nested queries. + // Examples: + // * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") + // OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") + // + // * Filter Limits: + // * Filter should not contain more than 6 conditions. + // * Max nesting depth should not exceed 2 levels. + // + // Examples queries: + // * Delete back order products created before a timestamp. + // create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any products. + bool force = 3; +} + +// Response of the PurgeProductsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeProductsResponse { + // The total count of products purged as a result of the operation. + int64 purge_count = 1; + + // A sample of the product names that will be deleted. + // Only populated if `force` is set to false. A max of 100 names will be + // returned and the names are chosen at random. + repeated string purge_sample = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for PurgeUserEvents method. +message PurgeUserEventsRequest { + // Required. The resource name of the catalog under which the events are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The filter string to specify the events to be deleted with a + // length limit of 5,000 characters. Empty string filter is not allowed. The + // eligible fields for filtering are: + // + // * `eventType`: Double quoted + // [UserEvent.event_type][google.cloud.retail.v2alpha.UserEvent.event_type] + // string. + // * `eventTime`: in ISO 8601 "zulu" format. + // * `visitorId`: Double quoted string. Specifying this will delete all + // events associated with a visitor. + // * `userId`: Double quoted string. Specifying this will delete all events + // associated with a user. + // + // Examples: + // + // * Deleting all events in a time range: + // `eventTime > "2012-04-23T18:25:43.511Z" + // eventTime < "2012-04-23T18:30:43.511Z"` + // * Deleting specific eventType in time range: + // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + // * Deleting all events for a specific visitor: + // `visitorId = "visitor1024"` + // + // The filtering fields are assumed to have an implicit AND. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any user events. + bool force = 3; +} + +// Response of the PurgeUserEventsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeUserEventsResponse { + // The total count of events purged as a result of the operation. + int64 purged_events_count = 1; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto new file mode 100644 index 00000000..f9612734 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto @@ -0,0 +1,832 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service SearchService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" + body: "*" + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] +// method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Product][google.cloud.retail.v2alpha.Product] object, over which the + // facet values are computed. Facet key is case-sensitive. + // + // Allowed facet keys when + // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] + // is not specified: + // + // * textual_field = + // * "brands" + // * "categories" + // * "genders" + // * "ageGroups" + // * "availability" + // * "colorFamilies" + // * "colors" + // * "sizes" + // * "materials" + // * "patterns" + // * "conditions" + // * "attributes.key" + // * "pickupInStore" + // * "shipToStore" + // * "sameDayDelivery" + // * "nextDayDelivery" + // * "customFulfillment1" + // * "customFulfillment2" + // * "customFulfillment3" + // * "customFulfillment4" + // * "customFulfillment5" + // * "inventory(place_id,attributes.key)" + // + // * numerical_field = + // * "price" + // * "discount" + // * "rating" + // * "ratingCount" + // * "attributes.key" + // * "inventory(place_id,price)" + // * "inventory(place_id,original_price)" + // * "inventory(place_id,attributes.key)" + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. For example, when using + // "pickupInStore" as key and set restricted values to + // ["store123", "store456"], only facets for "store123" and "store456" are + // returned. Only supported on textual fields and fulfillments. + // Maximum is 20. + // + // Must be set for the fulfillment facet keys: + // + // * pickupInStore + // + // * shipToStore + // + // * sameDayDelivery + // + // * nextDayDelivery + // + // * customFulfillment1 + // + // * customFulfillment2 + // + // * customFulfillment3 + // + // * customFulfillment4 + // + // * customFulfillment5 + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the + // "categories" facet will give only "Women > Shoe" and "Women > Dress". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 8; + + // Only get facet values that contains the given strings. For example, + // suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the + // "categories" facet will give only "Women > Shoe" and "Men > Shoe". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 9; + + // The order in which [Facet.values][] are returned. + // + // Allowed values are: + // + // * "count desc", which means order by [Facet.FacetValue.count][] + // descending. + // + // * "value desc", which means order by [Facet.FacetValue.value][] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.intervals]; + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // are sorted in the order given by + // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.restricted_values]. + string order_by = 4; + + // The query that is used to compute facet for the given facet key. + // When provided, it will override the default behavior of facet + // computation. The query syntax is the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for detail syntax and limitations. Notice that there is no limitation + // on + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // when query is specified. + // + // In the response, [FacetValue.value][] will be always "1" and + // [FacetValue.count][] will be the number of results that matches the + // query. + // + // For example, you can set a customized facet for "shipToStore", + // where + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // is "customizedShipToStore", and + // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] + // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". + // Then the facet will count the products that are both in stock and ship + // to store "123". + string query = 5; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // By default, + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // For example, suppose there are 100 products with color facet "Red" and + // 200 products with color facet "Blue". A query containing the filter + // "colorFamilies:ANY("Red")" and have "colorFamilies" as + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // will by default return the "Red" with count 100. + // + // If this field contains "colorFamilies", then the query returns both the + // "Red" with count 100 and "Blue" with count 200, because the + // "colorFamilies" key is now excluded from the filter. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined by Google + // Retail Search. It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined by + // Google Retail Search. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how Google Retail Search orders "gender" and + // "rating" facets. However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // The specifications of dynamically generated facets. + message DynamicFacetSpec { + // Enum to control DynamicFacet mode + enum Mode { + // Default value. + MODE_UNSPECIFIED = 0; + + // Disable Dynamic Facet. + DISABLED = 1; + + // Automatic mode built by Google Retail Search. + ENABLED = 2; + } + + // Mode of the DynamicFacet feature. + // Defaults to + // [Mode.DISABLED][google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode.DISABLED] + // if it's unset. + Mode mode = 1; + } + + // Boost specification to boost certain items. + message BoostSpec { + // Boost applies to products which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue": + // * (id: ANY("product_1", "product_2")) AND (colorFamilies: + // ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a product matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 10. + repeated ConditionBoostSpec condition_boost_specs = 1; + + // Whether to skip boostspec validation. If this field is set to true, + // invalid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // will be ignored and valid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // will still be applied. + optional bool skip_boost_spec_validation = 2; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. This defaults to + // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by Google Retail Search. + AUTO = 3; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + + // Whether to pin unexpanded results. If this field is set to true, + // unexpanded products are always at the top of the search results, followed + // by the expanded results. + bool pin_unexpanded_results = 2; + } + + // The specification for personalization. + message PersonalizationSpec { + // The personalization mode of each search request. + enum Mode { + // Default value. Defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The relevance threshold of the search results. The higher relevance + // threshold is, the higher relevant results are shown and the less number of + // results are returned. + enum RelevanceThreshold { + // Default value. Defaults to + // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH]. + RELEVANCE_THRESHOLD_UNSPECIFIED = 0; + + // High relevance threshold. + HIGH = 1; + + // Medium relevance threshold. + MEDIUM = 2; + + // Low relevance threshold. + LOW = 3; + + // Lowest relevance threshold. + LOWEST = 4; + } + + // The search mode of each search request. + enum SearchMode { + // Default value. In this case both product search and faceted search will + // be performed. Both [SearchResponse.SearchResult] and + // [SearchResponse.Facet] will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only [SearchResponse.SearchResult] will be returned. + // [SearchResponse.Facet] will not be returned, even if + // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] + // or + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] + // is set. + PRODUCT_SEARCH_ONLY = 1; + + // Only faceted search will be performed. The product search will be + // disabled. + // + // When in this mode, one or both of [SearchRequest.facet_spec][] and + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] + // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only + // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the search engine placement, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` + // This field is used to identify the serving configuration name and the set + // of models that will be used to make the search. + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. + // + // Use "default_branch" as the branch ID or leave this field empty, to search + // products under the default branch. + string branch = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Raw search query. + string query = 3; + + // Required. A unique identifier for tracking visitors. For example, this + // could be implemented with an HTTP cookie, which should be able to uniquely + // identify a visitor on a single device. This unique identifier should not + // change if the visitor logs in or out of the website. + // + // This should be the same identifier as + // [UserEvent.visitor_id][google.cloud.retail.v2alpha.UserEvent.visitor_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; + + // User information. + UserInfo user_info = 5; + + // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to + // return. If unspecified, defaults to a reasonable value. The maximum allowed + // value is 120. Values above 120 will be coerced to 120. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 7; + + // A page token + // [SearchResponse.next_page_token][google.cloud.retail.v2alpha.SearchResponse.next_page_token], + // received from a previous + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 8; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the + // [Product][google.cloud.retail.v2alpha.Product]s deemed by the API as + // relevant) in search results. This field is only considered if + // [page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] is + // unset. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 offset = 9; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. Filter + // expression is case-sensitive. See more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string filter = 10; + + // The default filter that is applied when a user performs a search without + // checking any filters on the search page. + // + // The filter applied to every search request when quality improvement such as + // query expansion is needed. For example, if a query does not have enough + // results, an expanded query with + // [SearchRequest.canonical_filter][google.cloud.retail.v2alpha.SearchRequest.canonical_filter] + // will be returned as a supplement of the original query. This field is + // strongly recommended to achieve high search quality. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for more details about filter syntax. + string canonical_filter = 28; + + // The order in which products are returned. Products can be ordered by + // a field in an [Product][google.cloud.retail.v2alpha.Product] object. Leave + // it unset if ordered by relevance. OrderBy expression is case-sensitive. See + // more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#order). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string order_by = 11; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated FacetSpec facet_specs = 12; + + // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + // to enable dynamic facets. Do not set this field. + // + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; + + // Boost specification to boost certain products. See more details at this + // [user guide](https://cloud.google.com/retail/docs/boosting). + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] + // and [SearchRequest.boost_spec] are set, the boost conditions from both + // places are evaluated. If a search request matches multiple boost + // conditions, the final boost score is equal to the sum of the boost scores + // from all matched boost conditions. + BoostSpec boost_spec = 13; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + QueryExpansionSpec query_expansion_spec = 14; + + // The relevance threshold of the search results. + // + // Defaults to + // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH], + // which means only the most relevant results are shown, and the least number + // of results are returned. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + RelevanceThreshold relevance_threshold = 15; + + // The keys to fetch and rollup the matching + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s attributes, + // [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo] or + // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s attributes. + // The attributes from all the matching + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s or + // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s are merged + // and de-duplicated. Notice that rollup attributes will lead to extra query + // latency. Maximum number of keys is 30. + // + // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], a + // fulfillment type and a fulfillment ID must be provided in the format of + // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + // "pickupInStore" is fulfillment type and "store123" is the store ID. + // + // Supported keys are: + // + // * colorFamilies + // * price + // * originalPrice + // * discount + // * variantId + // * inventory(place_id,price) + // * inventory(place_id,original_price) + // * inventory(place_id,attributes.key), where key is any key in the + // [Product.inventories.attributes][] map. + // * attributes.key, where key is any key in the + // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes] map. + // * pickupInStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "pickup-in-store". + // * shipToStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "ship-to-store". + // * sameDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "same-day-delivery". + // * nextDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "next-day-delivery". + // * customFulfillment1.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-1". + // * customFulfillment2.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-2". + // * customFulfillment3.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-3". + // * customFulfillment4.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-4". + // * customFulfillment5.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-5". + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + repeated string variant_rollup_keys = 17; + + // The categories associated with a category page. Required for category + // navigation queries to achieve good search quality. The format should be + // the same as + // [UserEvent.page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories]; + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + repeated string page_categories = 23; + + // The search mode of the search request. If not specified, a single search + // request triggers both product search and faceted search. + SearchMode search_mode = 31; + + // The specification for personalization. + PersonalizationSpec personalization_spec = 32; +} + +// Response message for +// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] +// method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Product.id][google.cloud.retail.v2alpha.Product.id] of the searched + // [Product][google.cloud.retail.v2alpha.Product]. + string id = 1; + + // The product data snippet in the search response. Only + // [Product.name][google.cloud.retail.v2alpha.Product.name] is guaranteed to + // be populated. + // + // [Product.variants][google.cloud.retail.v2alpha.Product.variants] contains + // the product variants that match the search query. If there are multiple + // product variants matching the query, top 5 most relevant product variants + // are returned and ordered by relevancy. + // + // If relevancy can be deternmined, use + // [matching_variant_fields][google.cloud.retail.v2alpha.SearchResponse.SearchResult.matching_variant_fields] + // to look up matched product variants fields. If relevancy cannot be + // determined, e.g. when searching "shoe" all products in a shoe product can + // be a match, 5 product variants are returned but order is meaningless. + Product product = 2; + + // The count of matched + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s. + int32 matching_variant_count = 3; + + // If a [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] matches the search query, + // this map indicates which [Product][google.cloud.retail.v2alpha.Product] + // fields are matched. The key is the + // [Product.name][google.cloud.retail.v2alpha.Product.name], the value is a + // field mask of the matched [Product][google.cloud.retail.v2alpha.Product] + // fields. If matched attributes cannot be determined, this map will be + // empty. + // + // For example, a key "sku1" with field mask + // "products.color_info" indicates there is a match between + // "sku1" [ColorInfo][google.cloud.retail.v2alpha.ColorInfo] and the query. + map matching_variant_fields = 4; + + // The rollup matching + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] attributes. The key is one + // of the + // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2alpha.SearchRequest.variant_rollup_keys]. + // The values are the merged and de-duplicated + // [Product][google.cloud.retail.v2alpha.Product] attributes. Notice that + // the rollup values are respect filter. For example, when filtering by + // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is + // returned. + // + // For textual and numerical attributes, the rollup values is a list of + // string or double values with type + // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if + // there are two variants with colors "red" and "blue", the rollup values + // are + // + // { key: "colorFamilies" + // value { + // list_value { + // values { string_value: "red" } + // values { string_value: "blue" } + // } + // } + // } + // + // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], the + // rollup values is a double value with type + // [google.protobuf.Value][google.protobuf.Value]. For example, + // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there + // are 10 variants in this product are available in the store "store1". + map variant_rollup_values = 5; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colorFamilies". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + } + + // The key for this facet. E.g., "colorFamilies" or "price" or + // "attributes.attr1". + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Information describing query expansion including whether expansion has + // occurred. + message QueryExpansionInfo { + // Bool describing whether query expansion has occurred. + bool expanded_query = 1; + + // Number of pinned results. This field will only be set when expansion + // happens and + // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] + // is set to true. + int64 pinned_result_count = 2; + } + + // A list of matched items. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.retail.v2alpha.SearchResponse.results] + // returned by pagination may be less than the + // [total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] that + // matches. + int32 total_size = 3; + + // If spell correction applies, the corrected query. Otherwise, empty. + string corrected_query = 4; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this + // search, which enables accurate attribution of search model performance. + string attribution_token = 5; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 6; + + // Query expansion information for the returned results. + QueryExpansionInfo query_expansion_info = 7; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search will be performed, and only + // [redirect_uri][google.cloud.retail.v2alpha.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] + // will be set in the response. + string redirect_uri = 10; + + // The fully qualified resource name of applied + // [controls](https://cloud.google.com/retail/docs/serving-control-rules). + repeated string applied_controls = 12; + + // The invalid + // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto new file mode 100644 index 00000000..c339f310 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto @@ -0,0 +1,247 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configures metadata that is used to generate serving time results (e.g. +// search results or recommendation predictions). +// The ServingConfig is passed in the search and predict request and together +// with the Catalog.default_branch, generates results. +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // Immutable. Fully qualified name + // projects/*/locations/global/catalogs/*/servingConfig/* + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable serving config display name. Used in Retail + // UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // The id of the model to use at serving time. + // Currently only RecommendationModels are supported: + // https://cloud.google.com/retail/recommendations-ai/docs/create-models + // Can be changed but only to a compatible model (e.g. + // others-you-may-like CTR to others-you-may-like CVR). + // + // Required when + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string model_id = 3; + + // How much price ranking we want in serving results. + // Price reranking causes product items with a similar + // recommendation probability to be ordered by price, with the + // highest-priced items first. This setting could result in a decrease in + // click-through and conversion rates. + // Allowed values are: + // + // * 'no-price-reranking' + // * 'low-price-raranking' + // * 'medium-price-reranking' + // * 'high-price-reranking' + // + // If not specified, we choose default based on model type. Default value: + // 'no-price-reranking'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string price_reranking_level = 4; + + // Facet specifications for faceted search. If empty, no facets are returned. + // The ids refer to the ids of [Control][google.cloud.retail.v2alpha.Control] + // resources with only the Facet control set. These controls are assumed to be + // in the same [Catalog][google.cloud.retail.v2alpha.Catalog] as the + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]. + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string facet_control_ids = 5; + + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; + + // Condition boost specifications. If a product matches multiple conditions + // in the specifications, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 100. + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] + // and [SearchRequest.boost_spec] are set, the boost conditions from both + // places are evaluated. If a search request matches multiple boost + // conditions, the final boost score is equal to the sum of the boost scores + // from all matched boost conditions. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string boost_control_ids = 7; + + // Condition filter specifications. If a product matches multiple conditions + // in the specifications, filters from these specifications are all + // applied and combined via the AND operator. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string filter_control_ids = 9; + + // Condition redirect specifications. Only the first triggered redirect action + // is applied, even if multiple apply. Maximum number of specifications is + // 1000. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string redirect_control_ids = 10; + + // Condition synonyms specifications. If multiple syonyms conditions match, + // all matching synonyms control in the list will execute. Order of controls + // in the list will not matter. Maximum number of specifications is + // 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string twoway_synonyms_control_ids = 18; + + // Condition oneway synonyms specifications. If multiple oneway synonyms + // conditions match, all matching oneway synonyms controls in the list will + // execute. Order of controls in the list will not matter. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string oneway_synonyms_control_ids = 12; + + // Condition do not associate specifications. If multiple do not associate + // conditions match, all matching do not associate controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string do_not_associate_control_ids = 13; + + // Condition replacement specifications. + // - Applied according to the order in the list. + // - A previously replaced term can not be re-replaced. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string replacement_control_ids = 14; + + // Condition ignore specifications. If multiple ignore + // conditions match, all matching ignore controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string ignore_control_ids = 15; + + // How much diversity to use in recommendation model results e.g. + // 'medium-diversity' or 'high-diversity'. Currently supported values: + // + // * 'no-diversity' + // * 'low-diversity' + // * 'medium-diversity' + // * 'high-diversity' + // * 'auto-diversity' + // + // If not specified, we choose default based on recommendation model + // type. Default value: 'no-diversity'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string diversity_level = 8; + + // Whether to add additional category filters on the 'similar-items' model. + // If not specified, we enable it by default. + // Allowed values are: + // + // * 'no-category-match': No additional filtering of original results from + // the model and the customer's filters. + // * 'relaxed-category-match': Only keep results with categories that match + // at least one item categories in the PredictRequests's context item. + // * If customer also sends filters in the PredictRequest, then the results + // will satisfy both conditions (user given and category match). + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string enable_category_filter_level = 16; + + // Required. Immutable. Specifies the solution types that a serving config can + // be associated with. Currently we support setting only one type of solution. + repeated SolutionType solution_types = 19 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto new file mode 100644 index 00000000..48286797 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto @@ -0,0 +1,241 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/serving_config.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for modifying ServingConfig. +service ServingConfigService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a ServingConfig. + // + // A maximum of 100 + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in + // a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a + // FAILED_PRECONDITION error is returned. + rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + body: "serving_config" + }; + option (google.api.method_signature) = + "parent,serving_config,serving_config_id"; + } + + // Deletes a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc DeleteServingConfig(DeleteServingConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a ServingConfig. + rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + patch: "/v2alpha/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + body: "serving_config" + }; + option (google.api.method_signature) = "serving_config,update_mask"; + } + + // Gets a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all ServingConfigs linked to this catalog. + rpc ListServingConfigs(ListServingConfigsRequest) + returns (ListServingConfigsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Enables a Control on the specified ServingConfig. + // The control is added in the last position of the list of controls + // it belongs to (e.g. if it's a facet spec control it will be applied + // in the last position of servingConfig.facetSpecIds) + // Returns a ALREADY_EXISTS error if the control has already been applied. + // Returns a FAILED_PRECONDITION error if the addition could exceed maximum + // number of control allowed for that type of control. + rpc AddControl(AddControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } + + // Disables a Control on the specified ServingConfig. + // The control is removed from the ServingConfig. + // Returns a NOT_FOUND error if the Control is not enabled for the + // ServingConfig. + rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } +} + +// Request for CreateServingConfig method. +message CreateServingConfigRequest { + // Required. Full resource name of parent. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The ServingConfig to create. + ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the ServingConfig, which will become the final + // component of the ServingConfig's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateServingConfig method. +message UpdateServingConfigRequest { + // Required. The ServingConfig to update. + ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to update. The + // following are NOT supported: + // + // * [ServingConfig.name][google.cloud.retail.v2alpha.ServingConfig.name] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteServingConfig method. +message DeleteServingConfigRequest { + // Required. The resource name of the ServingConfig to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for GetServingConfig method. +message GetServingConfigRequest { + // Required. The resource name of the ServingConfig to get. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for ListServingConfigs method. +message ListServingConfigsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 100. If a value greater than 100 is provided, at most 100 results are + // returned. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListServingConfigs` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListServingConfigs method. +message ListServingConfigsResponse { + // All the ServingConfigs for a given catalog. + repeated ServingConfig serving_configs = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request for AddControl method. +message AddControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config - if id is not found a NOT_FOUND error is returned. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for RemoveControl method. +message RemoveControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto new file mode 100644 index 00000000..94f72879 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto @@ -0,0 +1,344 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// UserEvent captures all metadata information Retail API needs to know about +// how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // * `add-to-cart`: Products being added to cart. + // * `category-page-view`: Special pages such as sale or promotion pages + // viewed. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed. + // * `promotion-offered`: Promotion is offered to a user. + // * `promotion-not-offered`: Promotion is not offered to a user. + // * `purchase-complete`: User finishing a purchase. + // * `search`: Product search. + // * `shopping-cart-page-view`: User viewing a shopping cart. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A unique identifier for tracking visitors. + // + // For example, this could be implemented with an HTTP cookie, which should be + // able to uniquely identify a visitor on a single device. This unique + // identifier should not change if the visitor log in/out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analystics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the sesion_id: + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // visitor_id as prefix. + string session_id = 21; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.retail.v2alpha.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups (e.g. using Retail API, using different + // recommendation models). + repeated string experiment_ids = 4; + + // Highly recommended for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be a valid + // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] + // for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. + // The value must be a valid + // [SearchResponse.attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] + // for user events that are the result of + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // This token enables us to accurately attribute page view or purchase back to + // the event and the particular predict response containing this + // clicked/purchased product. If user clicks on product K in the + // recommendation results, pass + // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] + // as a URL parameter to product K's page. When recording events on product + // K's page, log the + // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] + // to this field. + string attribution_token = 5; + + // The main product details related to the event. + // + // This field is required for the following event types: + // + // * `add-to-cart` + // * `detail-page-view` + // * `purchase-complete` + // * `search` + // + // In a `search` event, this field represents the products returned to the end + // user on the current page (the end user may have not finished browsing the + // whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [product_details][google.cloud.retail.v2alpha.UserEvent.product_details] is + // desired. The end user may have not finished browsing the whole page yet. + repeated ProductDetail product_details = 6; + + // The main auto-completion details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionDetail completion_detail = 22; + + // Extra user event features to include in the recommendation model. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Retail API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // traffic_channel, which is how a user arrives at the site. Users can arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 7; + + // The ID or name of the associated shopping cart. This ID is used + // to associate multiple items added or present in the cart before purchase. + // + // This can only be set for `add-to-cart`, `purchase-complete`, or + // `shopping-cart-page-view` events. + string cart_id = 8; + + // A transaction represents the entire purchase transaction. + // + // Required for `purchase-complete` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + PurchaseTransaction purchase_transaction = 9; + + // The user's search query. + // + // See [SearchRequest.query][google.cloud.retail.v2alpha.SearchRequest.query] + // for definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 10; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 16; + + // The order in which products are returned. + // + // See + // [SearchRequest.order_by][google.cloud.retail.v2alpha.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 17; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See + // [SearchRequest.offset][google.cloud.retail.v2alpha.SearchRequest.offset] + // for definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + int32 offset = 18; + + // The categories associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + // + // Required for `category-page-view` events. At least one of + // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string page_categories = 11; + + // User information. + UserInfo user_info = 12; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 13; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string referrer_uri = 14; + + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string page_view_id = 15; +} + +// Detailed product information associated with a user event. +message ProductDetail { + // Required. [Product][google.cloud.retail.v2alpha.Product] information. + // + // Required field(s): + // + // * [Product.id][google.cloud.retail.v2alpha.Product.id] + // + // Optional override field(s): + // + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // + // If any supported optional fields are provided, we will treat them as a full + // override when looking up product information from the catalog. Thus, it is + // important to ensure that the overriding fields are accurate and + // complete. + // + // All other product fields are ignored and instead populated via catalog + // lookup after event ingestion. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Quantity of the product associated with the user event. + // + // For example, this field will be 2 if two products are added to the shopping + // cart for `purchase-complete` event. Required for `add-to-cart` and + // `purchase-complete` event types. + google.protobuf.Int32Value quantity = 2; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionDetail { + // Completion attribution token in + // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2alpha.CompleteQueryResponse.attribution_token]. + string completion_attribution_token = 1; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion]. + string selected_suggestion = 2; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion] + // position, starting from 0. + int32 selected_position = 3; +} + +// A transaction represents the entire purchase transaction. +message PurchaseTransaction { + // The transaction ID with a length limit of 128 characters. + string id = 1; + + // Required. Total non-zero revenue or grand total associated with the + // transaction. This value include shipping, tax, or other adjustments to + // total revenue that you want to include as part of your revenue + // calculations. + float revenue = 2 [(google.api.field_behavior) = REQUIRED]; + + // All the taxes associated with the transaction. + float tax = 3; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = + // [revenue][google.cloud.retail.v2alpha.PurchaseTransaction.revenue] - + // [tax][google.cloud.retail.v2alpha.PurchaseTransaction.tax] - + // [cost][google.cloud.retail.v2alpha.PurchaseTransaction.cost] + float cost = 4; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto new file mode 100644 index 00000000..af97dad9 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto @@ -0,0 +1,190 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; +import "google/cloud/retail/v2alpha/purge_config.proto"; +import "google/cloud/retail/v2alpha/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for ingesting end user actions on the customer website. +service UserEventService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" + body: "user_event" + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Retail API JavaScript pixel and Google Tag + // Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }; + } + + // Deletes permanently all user events specified by the filter provided. + // Depending on the number of events specified by the filter, this operation + // could take hours or days to complete. To test a filter, use the list + // command first. + rpc PurgeUserEvents(PurgeUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.PurgeUserEventsResponse" + metadata_type: "google.cloud.retail.v2alpha.PurgeMetadata" + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // Operation.response is of type ImportResponse. Note that it is + // possible for a subset of the items to be successfully inserted. + // Operation.metadata is of type ImportMetadata. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.ImportUserEventsResponse" + metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" + }; + } + + // Starts a user event rejoin operation with latest product catalog. Events + // will not be annotated with detailed product information if product is + // missing from the catalog at the time the user event is ingested, and these + // events are stored as unjoined events with a limited usage on training and + // serving. This method can be used to start a join operation on specified + // events with latest version of product catalog. It can also be used to + // correct events joined with the wrong product catalog. A rejoin operation + // can take hours or days to complete. + rpc RejoinUserEvents(RejoinUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "RejoinUserEventsResponse" + metadata_type: "RejoinUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User event to write. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent catalog name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // The URL including cgi-parameters but excluding the hash fragment with a + // length limit of 5,000 characters. This is often more useful than the + // referer URL, because many browsers only send the domain for 3rd party + // requests. + string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + int64 ets = 4; +} + +// Request message for RejoinUserEvents method. +message RejoinUserEventsRequest { + // The scope of user events to be rejoined with the latest product catalog. + // If the rejoining aims at reducing number of unjoined events, set + // UserEventRejoinScope to UNJOINED_EVENTS. + // If the rejoining aims at correcting product catalog information in joined + // events, set UserEventRejoinScope to JOINED_EVENTS. + // If all events needs to be rejoined, set UserEventRejoinScope to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. + enum UserEventRejoinScope { + // Rejoin all events with the latest product catalog, including both joined + // events and unjoined events. + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; + + // Only rejoin joined events with the latest product catalog. + JOINED_EVENTS = 1; + + // Only rejoin unjoined events with the latest product catalog. + UNJOINED_EVENTS = 2; + } + + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the user event rejoin to define the scope and range of the user + // events to be rejoined with the latest product catalog. Defaults to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + // invalid integer value. + UserEventRejoinScope user_event_rejoin_scope = 2; +} + +// Response message for RejoinUserEvents method. +message RejoinUserEventsResponse { + // Number of user events that were joined with latest product catalog. + int64 rejoined_user_events_count = 1; +} + +// Metadata for RejoinUserEvents method. +message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000..0a46b0bb --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to add. + */ + // const catalogAttribute = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callAddCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.addCatalogAttribute(request); + console.log(response); + } + + callAddCatalogAttribute(); + // [END retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js new file mode 100644 index 00000000..8fe314bf --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_CatalogService_GetAttributesConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetAttributesConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getAttributesConfig(request); + console.log(response); + } + + callGetAttributesConfig(); + // [END retail_v2alpha_generated_CatalogService_GetAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js new file mode 100644 index 00000000..b189f66e --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_CatalogService_GetCompletionConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetCompletionConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getCompletionConfig(request); + console.log(response); + } + + callGetCompletionConfig(); + // [END retail_v2alpha_generated_CatalogService_GetCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js new file mode 100644 index 00000000..075a2b10 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js @@ -0,0 +1,58 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2alpha_generated_CatalogService_GetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.getDefaultBranch(request); + console.log(response); + } + + callGetDefaultBranch(); + // [END retail_v2alpha_generated_CatalogService_GetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js new file mode 100644 index 00000000..2bed2f3f --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_CatalogService_ListCatalogs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The account resource name with an associated location. + * If the caller does not have permission to list + * Catalog google.cloud.retail.v2alpha.Catalog s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Catalog google.cloud.retail.v2alpha.Catalog s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListCatalogsResponse.next_page_token google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token, + * received from a previous + * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callListCatalogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCatalogs(); + // [END retail_v2alpha_generated_CatalogService_ListCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000..81358df9 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, key) { + // [START retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name key of the + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to remove. + */ + // const key = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callRemoveCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + key, + }; + + // Run request + const response = await retailClient.removeCatalogAttribute(request); + console.log(response); + } + + callRemoveCatalogAttribute(); + // [END retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000..2fdfc582 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.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(attributesConfig, catalogAttribute) { + // [START retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The updated + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute. + */ + // const catalogAttribute = {} + /** + * Indicates which fields in the provided + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to update. + * The following are NOT supported: + * * CatalogAttribute.key google.cloud.retail.v2alpha.CatalogAttribute.key + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callReplaceCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.replaceCatalogAttribute(request); + console.log(response); + } + + callReplaceCatalogAttribute(); + // [END retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js new file mode 100644 index 00000000..7fce54ef --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2alpha_generated_CatalogService_SetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * The final component of the resource name of a branch. + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * If there are no sufficient active products in the targeted branch and + * force google.cloud.retail.v2alpha.SetDefaultBranchRequest.force is not + * set, a FAILED_PRECONDITION error is returned. + */ + // const branchId = 'abc123' + /** + * Some note on this request, this can be retrieved by + * CatalogService.GetDefaultBranch google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch + * before next valid default branch set occurs. + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const note = 'abc123' + /** + * If set to true, it permits switching to a branch with + * branch_id google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id + * even if it has no sufficient active products. + */ + // const force = true + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callSetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.setDefaultBranch(request); + console.log(response); + } + + callSetDefaultBranch(); + // [END retail_v2alpha_generated_CatalogService_SetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js new file mode 100644 index 00000000..bf5828a2 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.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(attributesConfig) { + // [START retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The + * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. + */ + // const attributesConfig = {} + /** + * Indicates which fields in the provided + * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. + * The following is the only supported field: + * * AttributesConfig.catalog_attributes google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateAttributesConfig() { + // Construct request + const request = { + attributesConfig, + }; + + // Run request + const response = await retailClient.updateAttributesConfig(request); + console.log(response); + } + + callUpdateAttributesConfig(); + // [END retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js new file mode 100644 index 00000000..81ee698f --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.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(catalog) { + // [START retail_v2alpha_generated_CatalogService_UpdateCatalog_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Catalog google.cloud.retail.v2alpha.Catalog to update. + * If the caller does not have permission to update the + * Catalog google.cloud.retail.v2alpha.Catalog, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the Catalog google.cloud.retail.v2alpha.Catalog to update does not + * exist, a NOT_FOUND error is returned. + */ + // const catalog = {} + /** + * Indicates which fields in the provided + * Catalog google.cloud.retail.v2alpha.Catalog to update. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCatalog() { + // Construct request + const request = { + catalog, + }; + + // Run request + const response = await retailClient.updateCatalog(request); + console.log(response); + } + + callUpdateCatalog(); + // [END retail_v2alpha_generated_CatalogService_UpdateCatalog_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js new file mode 100644 index 00000000..62e6eea3 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(completionConfig) { + // [START retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The + * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. + * If the caller does not have permission to update the + * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig, then a + * PERMISSION_DENIED error is returned. + * If the CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to + * update does not exist, a NOT_FOUND error is returned. + */ + // const completionConfig = {} + /** + * Indicates which fields in the provided + * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. + * The following are the only supported fields: + * * CompletionConfig.matching_order google.cloud.retail.v2alpha.CompletionConfig.matching_order + * * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions + * * CompletionConfig.min_prefix_length google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length + * * CompletionConfig.auto_learning google.cloud.retail.v2alpha.CompletionConfig.auto_learning + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCompletionConfig() { + // Construct request + const request = { + completionConfig, + }; + + // Run request + const response = await retailClient.updateCompletionConfig(request); + console.log(response); + } + + callUpdateCompletionConfig(); + // [END retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js new file mode 100644 index 00000000..6f768b76 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js @@ -0,0 +1,117 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog, query) { + // [START retail_v2alpha_generated_CompletionService_CompleteQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Catalog for which the completion is performed. + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * Required. The query used to generate suggestions. + * The maximum number of allowed characters is 255. + */ + // const query = 'abc123' + /** + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see Tags for + * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + */ + // const languageCodes = 'abc123' + /** + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * Supported formats: + * * `UNKNOWN_DEVICE_TYPE` + * * `DESKTOP` + * * `MOBILE` + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + */ + // const deviceType = 'abc123' + /** + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * CompletionService.ImportCompletionData google.cloud.retail.v2alpha.CompletionService.ImportCompletionData. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * Current supported values: + * * user-data + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + */ + // const dataset = 'abc123' + /** + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions. + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + catalog, + query, + }; + + // Run request + const response = await retailClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END retail_v2alpha_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js new file mode 100644 index 00000000..b54422e5 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.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, inputConfig) { + // [START retail_v2alpha_generated_CompletionService_ImportCompletionData_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog which the suggestions dataset belongs to. + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callImportCompletionData() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importCompletionData(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportCompletionData(); + // [END retail_v2alpha_generated_CompletionService_ImportCompletionData_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js new file mode 100644 index 00000000..bacd422a --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.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, control, controlId) { + // [START retail_v2alpha_generated_ControlService_CreateControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of parent catalog. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Required. The Control to create. + */ + // const control = {} + /** + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callCreateControl() { + // Construct request + const request = { + parent, + control, + controlId, + }; + + // Run request + const response = await retailClient.createControl(request); + console.log(response); + } + + callCreateControl(); + // [END retail_v2alpha_generated_ControlService_CreateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js new file mode 100644 index 00000000..6afa1e03 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ControlService_DeleteControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callDeleteControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteControl(request); + console.log(response); + } + + callDeleteControl(); + // [END retail_v2alpha_generated_ControlService_DeleteControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js new file mode 100644 index 00000000..a0c4c927 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ControlService_GetControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callGetControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getControl(request); + console.log(response); + } + + callGetControl(); + // [END retail_v2alpha_generated_ControlService_GetControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js new file mode 100644 index 00000000..c09815fd --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_ControlService_ListControls_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + /** + * Optional. A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2alpha.ListControlsRequest.filter is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + */ + // const filter = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callListControls() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listControlsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListControls(); + // [END retail_v2alpha_generated_ControlService_ListControls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js new file mode 100644 index 00000000..7f0e4c67 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(control) { + // [START retail_v2alpha_generated_ControlService_UpdateControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Control to update. + */ + // const control = {} + /** + * Indicates which fields in the provided + * Control google.cloud.retail.v2alpha.Control to update. The following are + * NOT supported: + * * Control.name google.cloud.retail.v2alpha.Control.name + * If not set or empty, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callUpdateControl() { + // Construct request + const request = { + control, + }; + + // Run request + const response = await retailClient.updateControl(request); + console.log(response); + } + + callUpdateControl(); + // [END retail_v2alpha_generated_ControlService_UpdateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js new file mode 100644 index 00000000..f49c45f1 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js @@ -0,0 +1,161 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, userEvent) { + // [START retail_v2alpha_generated_PredictionService_Predict_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see Managing + * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + */ + // const placement = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + */ + // const userEvent = {} + /** + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + */ + // const pageSize = 1234 + /** + * The previous PredictResponse.next_page_token. + */ + // const pageToken = 'abc123' + /** + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * Examples: + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + */ + // const filter = 'abc123' + /** + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + */ + // const validateOnly = true + /** + * Additional domain specific parameters for the predictions. + * Allowed values: + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + */ + // const params = 1234 + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + + // Imports the Retail library + const {PredictionServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new PredictionServiceClient(); + + async function callPredict() { + // Construct request + const request = { + placement, + userEvent, + }; + + // Run request + const response = await retailClient.predict(request); + console.log(response); + } + + callPredict(); + // [END retail_v2alpha_generated_PredictionService_Predict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js new file mode 100644 index 00000000..c15b5aa0 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type. + * Duplicate IDs will be automatically ignored. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * If the total number of place IDs exceeds 2000 for this + * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type after + * adding, then the update will be rejected. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddFulfillmentPlaces(); + // [END retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js new file mode 100644 index 00000000..1a0bcb74 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js @@ -0,0 +1,100 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, localInventories) { + // [START retail_v2alpha_generated_ProductService_AddLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + */ + // const localInventories = 1234 + /** + * Indicates which inventory fields in the provided list of + * LocalInventory google.cloud.retail.v2alpha.LocalInventory to update. The + * field is updated to the provided value. + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const addMask = {} + /** + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddLocalInventories() { + // Construct request + const request = { + product, + localInventories, + }; + + // Run request + const [operation] = await retailClient.addLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddLocalInventories(); + // [END retail_v2alpha_generated_ProductService_AddLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js new file mode 100644 index 00000000..d452aae4 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, product, productId) { + // [START retail_v2alpha_generated_ProductService_CreateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + */ + // const parent = 'abc123' + /** + * Required. The Product google.cloud.retail.v2alpha.Product to create. + */ + // const product = {} + /** + * Required. The ID to use for the + * Product google.cloud.retail.v2alpha.Product, which will become the final + * component of the Product.name google.cloud.retail.v2alpha.Product.name. + * If the caller does not have permission to create the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * This field must be unique among all + * Product google.cloud.retail.v2alpha.Product s with the same + * parent google.cloud.retail.v2alpha.CreateProductRequest.parent. + * Otherwise, an ALREADY_EXISTS error is returned. + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const productId = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + productId, + }; + + // Run request + const response = await retailClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END retail_v2alpha_generated_ProductService_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js new file mode 100644 index 00000000..7470b33d --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_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(name) { + // [START retail_v2alpha_generated_ProductService_DeleteProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to delete the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2alpha.Product to delete does not + * exist, a NOT_FOUND error is returned. + * The Product google.cloud.retail.v2alpha.Product to delete can neither be + * a + * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION + * Product google.cloud.retail.v2alpha.Product member nor a + * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY + * Product google.cloud.retail.v2alpha.Product with more than one + * variants google.cloud.retail.v2alpha.Product.Type.VARIANT. Otherwise, an + * INVALID_ARGUMENT error is returned. + * All inventory information for the named + * Product google.cloud.retail.v2alpha.Product will be deleted. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END retail_v2alpha_generated_ProductService_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js new file mode 100644 index 00000000..52340240 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ProductService_GetProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the requested Product google.cloud.retail.v2alpha.Product does not + * exist, a NOT_FOUND error is returned. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END retail_v2alpha_generated_ProductService_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js new file mode 100644 index 00000000..26a70a51 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js @@ -0,0 +1,93 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2alpha_generated_ProductService_ImportProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. + */ + // const errorsConfig = {} + /** + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + */ + // const updateMask = {} + /** + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * Only supported when + * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode + * is set to `FULL`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callImportProducts() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProducts(); + // [END retail_v2alpha_generated_ProductService_ImportProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js new file mode 100644 index 00000000..a9e1ed2f --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js @@ -0,0 +1,141 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_ProductService_ListProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * If the caller does not have permission to list + * Product google.cloud.retail.v2alpha.Product s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Product google.cloud.retail.v2alpha.Product s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT error is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListProductsResponse.next_page_token google.cloud.retail.v2alpha.ListProductsResponse.next_page_token, + * received from a previous + * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2alpha.ListProductsRequest.filter is unset. + * * List + * Product.Type.VARIANT google.cloud.retail.v2alpha.Product.Type.VARIANT + * Product google.cloud.retail.v2alpha.Product s sharing the same + * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY + * Product google.cloud.retail.v2alpha.Product. For example: + * `primary_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2alpha.Product s bundled in a + * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION + * Product google.cloud.retail.v2alpha.Product. + * For example: + * `collection_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2alpha.Product s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * If the specified + * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY + * Product google.cloud.retail.v2alpha.Product or + * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION + * Product google.cloud.retail.v2alpha.Product does not exist, a NOT_FOUND + * error is returned. + */ + // const filter = 'abc123' + /** + * The fields of Product google.cloud.retail.v2alpha.Product to return in + * the responses. If not set or empty, the following fields are returned: + * * Product.name google.cloud.retail.v2alpha.Product.name + * * Product.id google.cloud.retail.v2alpha.Product.id + * * Product.title google.cloud.retail.v2alpha.Product.title + * * Product.uri google.cloud.retail.v2alpha.Product.uri + * * Product.images google.cloud.retail.v2alpha.Product.images + * * Product.price_info google.cloud.retail.v2alpha.Product.price_info + * * Product.brands google.cloud.retail.v2alpha.Product.brands + * If "*" is provided, all fields are returned. + * Product.name google.cloud.retail.v2alpha.Product.name is always returned + * no matter what mask is set. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const readMask = {} + /** + * If true and + * page_token google.cloud.retail.v2alpha.ListProductsRequest.page_token is + * empty, + * ListProductsResponse.total_size google.cloud.retail.v2alpha.ListProductsResponse.total_size + * is set to the total count of matched items irrespective of pagination. + * Notice that setting this field to true affects the performance. + */ + // const requireTotalSize = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END retail_v2alpha_generated_ProductService_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js new file mode 100644 index 00000000..55d09aef --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js @@ -0,0 +1,101 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2alpha_generated_ProductService_PurgeProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the branch under which the products are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the products to be deleted with a + * length limit of 5,000 characters. + * Empty string filter is not allowed. "*" implies delete all items in a + * branch. + * The eligible fields for filtering are: + * * `availability`: Double quoted + * Product.availability google.cloud.retail.v2alpha.Product.availability + * string. + * * `create_time` : in ISO 8601 "zulu" format. + * Supported syntax: + * * Comparators (">", "<", ">=", "<=", "="). + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" + * * availability = "IN_STOCK" + * * Conjunctions ("AND") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" + * * Disjunctions ("OR") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" + * * Can support nested queries. + * Examples: + * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") + * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") + * * Filter Limits: + * * Filter should not contain more than 6 conditions. + * * Max nesting depth should not exceed 2 levels. + * Examples queries: + * * Delete back order products created before a timestamp. + * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any products. + */ + // const force = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END retail_v2alpha_generated_ProductService_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000..9543acde --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js @@ -0,0 +1,111 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveFulfillmentPlaces(); + // [END retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js new file mode 100644 index 00000000..903fe738 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, placeIds) { + // [START retail_v2alpha_generated_ProductService_RemoveLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + */ + // const placeIds = 'abc123' + /** + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveLocalInventories() { + // Construct request + const request = { + product, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveLocalInventories(); + // [END retail_v2alpha_generated_ProductService_RemoveLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js new file mode 100644 index 00000000..00d04376 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js @@ -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 +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inventory) { + // [START retail_v2alpha_generated_ProductService_SetInventory_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The inventory information to update. The allowable fields to + * update are: + * * Product.price_info google.cloud.retail.v2alpha.Product.price_info + * * Product.availability google.cloud.retail.v2alpha.Product.availability + * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info + * The updated inventory fields must be specified in + * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask. + * If SetInventoryRequest.inventory.name is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2alpha.Product named in + * Product.name google.cloud.retail.v2alpha.Product.name, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2alpha.Product to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * If the Product google.cloud.retail.v2alpha.Product to update has + * existing inventory information, the provided inventory information will be + * merged while respecting the last update time for each inventory field, + * using the provided or default value for + * SetInventoryRequest.set_time google.cloud.retail.v2alpha.SetInventoryRequest.set_time. + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in SetInventoryRequest.inventory.fulfillment_info + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types to clear in + * SetInventoryRequest.inventory.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids + * The last update time is recorded for the following inventory fields: + * * Product.price_info google.cloud.retail.v2alpha.Product.price_info + * * Product.availability google.cloud.retail.v2alpha.Product.availability + * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info + * If a full overwrite of inventory information while ignoring timestamps is + * needed, UpdateProduct should be invoked instead. + */ + // const inventory = {} + /** + * Indicates which inventory fields in the provided + * Product google.cloud.retail.v2alpha.Product to update. + * At least one field must be provided. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const setMask = {} + /** + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + */ + // const setTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product with + * name Product.name google.cloud.retail.v2alpha.Product.name is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the Product google.cloud.retail.v2alpha.Product is created. If set + * to false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callSetInventory() { + // Construct request + const request = { + inventory, + }; + + // Run request + const [operation] = await retailClient.setInventory(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInventory(); + // [END retail_v2alpha_generated_ProductService_SetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js new file mode 100644 index 00000000..db9b00e4 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START retail_v2alpha_generated_ProductService_UpdateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The product to update/create. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2alpha.Product to update does not + * exist and + * allow_missing google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing + * is not set, a NOT_FOUND error is returned. + */ + // const product = {} + /** + * Indicates which fields in the provided + * Product google.cloud.retail.v2alpha.Product to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, a new Product google.cloud.retail.v2alpha.Product will be + * created. In this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await retailClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END retail_v2alpha_generated_ProductService_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js new file mode 100644 index 00000000..9c4c8b0d --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js @@ -0,0 +1,281 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, visitorId) { + // [START retail_v2alpha_generated_SearchService_Search_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + */ + // const placement = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + */ + // const query = 'abc123' + /** + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * This should be the same identifier as + * UserEvent.visitor_id google.cloud.retail.v2alpha.UserEvent.visitor_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * User information. + */ + // const userInfo = {} + /** + * Maximum number of Product google.cloud.retail.v2alpha.Product s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * SearchResponse.next_page_token google.cloud.retail.v2alpha.SearchResponse.next_page_token, + * received from a previous + * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * Product google.cloud.retail.v2alpha.Product s deemed by the API as + * relevant) in search results. This field is only considered if + * page_token google.cloud.retail.v2alpha.SearchRequest.page_token is + * unset. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const filter = 'abc123' + /** + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * SearchRequest.canonical_filter google.cloud.retail.v2alpha.SearchRequest.canonical_filter + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * See + * SearchRequest.filter google.cloud.retail.v2alpha.SearchRequest.filter + * for more details about filter syntax. + */ + // const canonicalFilter = 'abc123' + /** + * The order in which products are returned. Products can be ordered by + * a field in an Product google.cloud.retail.v2alpha.Product object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#order). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const orderBy = 'abc123' + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain products. See more details at this + * user guide (https://cloud.google.com/retail/docs/boosting). + * Notice that if both + * ServingConfig.boost_control_ids google.cloud.retail.v2alpha.ServingConfig.boost_control_ids + * and SearchRequest.boost_spec are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + */ + // const boostSpec = {} + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). + */ + // const queryExpansionSpec = {} + /** + * The relevance threshold of the search results. + * Defaults to + * RelevanceThreshold.HIGH google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + */ + // const relevanceThreshold = {} + /** + * The keys to fetch and rollup the matching + * variant google.cloud.retail.v2alpha.Product.Type.VARIANT + * Product google.cloud.retail.v2alpha.Product s attributes, + * FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo or + * LocalInventory google.cloud.retail.v2alpha.LocalInventory s attributes. + * The attributes from all the matching + * variant google.cloud.retail.v2alpha.Product.Type.VARIANT + * Product google.cloud.retail.v2alpha.Product s or + * LocalInventory google.cloud.retail.v2alpha.LocalInventory s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * For FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * Supported keys are: + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * Product.inventories.attributes map. + * * attributes.key, where key is any key in the + * Product.attributes google.cloud.retail.v2alpha.Product.attributes map. + * * pickupInStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "pickup-in-store". + * * shipToStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-1". + * * customFulfillment2.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-2". + * * customFulfillment3.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-3". + * * customFulfillment4.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-4". + * * customFulfillment5.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-5". + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + */ + // const variantRollupKeys = 'abc123' + /** + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * UserEvent.page_categories google.cloud.retail.v2alpha.UserEvent.page_categories; + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : "Sales > 2017 Black Friday Deals". + */ + // const pageCategories = 'abc123' + /** + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + */ + // const searchMode = {} + /** + * The specification for personalization. + */ + // const personalizationSpec = {} + + // Imports the Retail library + const {SearchServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + placement, + visitorId, + }; + + // Run request + const iterable = await retailClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END retail_v2alpha_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js new file mode 100644 index 00000000..5145a2cb --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2alpha_generated_ServingConfigService_AddControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callAddControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.addControl(request); + console.log(response); + } + + callAddControl(); + // [END retail_v2alpha_generated_ServingConfigService_AddControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js new file mode 100644 index 00000000..5a4982b7 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.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, servingConfig, servingConfigId) { + // [START retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of parent. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Required. The ServingConfig to create. + */ + // const servingConfig = {} + /** + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const servingConfigId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callCreateServingConfig() { + // Construct request + const request = { + parent, + servingConfig, + servingConfigId, + }; + + // Run request + const response = await retailClient.createServingConfig(request); + console.log(response); + } + + callCreateServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000..4ca230b4 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callDeleteServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteServingConfig(request); + console.log(response); + } + + callDeleteServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js new file mode 100644 index 00000000..b88b3af3 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callGetServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getServingConfig(request); + console.log(response); + } + + callGetServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000..b79bfca1 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.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 retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callListServingConfigs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listServingConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServingConfigs(); + // [END retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js new file mode 100644 index 00000000..c1ea7176 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2alpha_generated_ServingConfigService_RemoveControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callRemoveControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.removeControl(request); + console.log(response); + } + + callRemoveControl(); + // [END retail_v2alpha_generated_ServingConfigService_RemoveControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js new file mode 100644 index 00000000..7f236fba --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig) { + // [START retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ServingConfig to update. + */ + // const servingConfig = {} + /** + * Indicates which fields in the provided + * ServingConfig google.cloud.retail.v2alpha.ServingConfig to update. The + * following are NOT supported: + * * ServingConfig.name google.cloud.retail.v2alpha.ServingConfig.name + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callUpdateServingConfig() { + // Construct request + const request = { + servingConfig, + }; + + // Run request + const response = await retailClient.updateServingConfig(request); + console.log(response); + } + + callUpdateServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json b/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json new file mode 100644 index 00000000..1072ee94 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json @@ -0,0 +1,2187 @@ +{ + "clientLibrary": { + "name": "nodejs-retail", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.retail.v2alpha", + "version": "v2alpha" + } + ] + }, + "snippets": [ + { + "regionTag": "retail_v2alpha_generated_CatalogService_ListCatalogs_async", + "title": "CatalogService listCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated with the project.", + "canonical": true, + "file": "catalog_service.list_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListCatalogsResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCatalog_async", + "title": "CatalogService updateCatalog Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s.", + "canonical": true, + "file": "catalog_service.update_catalog.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": ".google.cloud.retail.v2alpha.Catalog" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Catalog", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_SetDefaultBranch_async", + "title": "CatalogService setDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", + "canonical": true, + "file": "catalog_service.set_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "branch_id", + "type": "TYPE_STRING" + }, + { + "name": "note", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_GetDefaultBranch_async", + "title": "CatalogService getDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] method under a specified parent catalog.", + "canonical": true, + "file": "catalog_service.get_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.GetDefaultBranchResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_GetCompletionConfig_async", + "title": "CatalogService getCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig].", + "canonical": true, + "file": "catalog_service.get_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async", + "title": "CatalogService updateCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s.", + "canonical": true, + "file": "catalog_service.update_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", + "async": true, + "parameters": [ + { + "name": "completion_config", + "type": ".google.cloud.retail.v2alpha.CompletionConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_GetAttributesConfig_async", + "title": "CatalogService getAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig].", + "canonical": true, + "file": "catalog_service.get_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async", + "title": "CatalogService updateAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", + "canonical": true, + "file": "catalog_service.update_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": ".google.cloud.retail.v2alpha.AttributesConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async", + "title": "CatalogService addCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "catalog_service.add_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2alpha.CatalogAttribute" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async", + "title": "CatalogService removeCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.remove_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "key", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async", + "title": "CatalogService replaceCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.replace_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2alpha.CatalogAttribute" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CompletionService_CompleteQuery_async", + "title": "CatalogService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 109, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "language_codes", + "type": "TYPE_STRING[]" + }, + { + "name": "device_type", + "type": "TYPE_STRING" + }, + { + "name": "dataset", + "type": "TYPE_STRING" + }, + { + "name": "max_suggestions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.retail.v2alpha.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2alpha.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CompletionService_ImportCompletionData_async", + "title": "CatalogService importCompletionData Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.import_completion_data.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2alpha.CompletionDataInputConfig" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" + }, + "method": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2alpha.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_CreateControl_async", + "title": "CatalogService createControl Sample", + "origin": "API_DEFINITION", + "description": " Creates a Control. If the [Control][google.cloud.retail.v2alpha.Control] to create already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "control_service.create_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "control", + "type": ".google.cloud.retail.v2alpha.Control" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_DeleteControl_async", + "title": "CatalogService deleteControl Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Control. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.delete_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_UpdateControl_async", + "title": "CatalogService updateControl Sample", + "origin": "API_DEFINITION", + "description": " Updates a Control. [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", + "async": true, + "parameters": [ + { + "name": "control", + "type": ".google.cloud.retail.v2alpha.Control" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_GetControl_async", + "title": "CatalogService getControl Sample", + "origin": "API_DEFINITION", + "description": " Gets a Control.", + "canonical": true, + "file": "control_service.get_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_ListControls_async", + "title": "CatalogService listControls Sample", + "origin": "API_DEFINITION", + "description": " Lists all Controls linked to this catalog.", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListControlsResponse", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_PredictionService_Predict_async", + "title": "CatalogService predict Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation prediction.", + "canonical": true, + "file": "prediction_service.predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 153, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2alpha.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.retail.v2alpha.PredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.retail.v2alpha.PredictionServiceClient" + }, + "method": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.retail.v2alpha.PredictionService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_CreateProduct_async", + "title": "CatalogService createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.retail.v2alpha.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_GetProduct_async", + "title": "CatalogService getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_ListProducts_async", + "title": "CatalogService listProducts Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Product][google.cloud.retail.v2alpha.Product]s.", + "canonical": true, + "file": "product_service.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 133, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "read_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "require_total_size", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListProductsResponse", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_UpdateProduct_async", + "title": "CatalogService updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.retail.v2alpha.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_DeleteProduct_async", + "title": "CatalogService deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_PurgeProducts_async", + "title": "CatalogService purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes all selected [Product][google.cloud.retail.v2alpha.Product]s under a branch. This process is asynchronous. If the request is valid, the removal will be enqueued and processed offline. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. Before the operation completes, some [Product][google.cloud.retail.v2alpha.Product]s may still be returned by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. To get a sample of [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] to false.", + "canonical": true, + "file": "product_service.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_ImportProducts_async", + "title": "CatalogService importProducts Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated.", + "canonical": true, + "file": "product_service.import_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2alpha.ProductInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_SetInventory_async", + "title": "CatalogService setInventory Sample", + "origin": "API_DEFINITION", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2alpha.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 116, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", + "async": true, + "parameters": [ + { + "name": "inventory", + "type": ".google.cloud.retail.v2alpha.Product" + }, + { + "name": "set_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "set_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async", + "title": "CatalogService addFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async", + "title": "CatalogService removeFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 103, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_AddLocalInventories_async", + "title": "CatalogService addLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Updates local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 92, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "local_inventories", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "add_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_RemoveLocalInventories_async", + "title": "CatalogService removeLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Remove local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_SearchService_Search_async", + "title": "CatalogService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 273, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2alpha.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.retail.v2alpha.UserInfo" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "canonical_filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "dynamic_facet_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec" + }, + { + "name": "boost_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.BoostSpec" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec" + }, + { + "name": "relevance_threshold", + "type": ".google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold" + }, + { + "name": "variant_rollup_keys", + "type": "TYPE_STRING[]" + }, + { + "name": "page_categories", + "type": "TYPE_STRING[]" + }, + { + "name": "search_mode", + "type": ".google.cloud.retail.v2alpha.SearchRequest.SearchMode" + }, + { + "name": "personalization_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec" + } + ], + "resultType": ".google.cloud.retail.v2alpha.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.retail.v2alpha.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2alpha.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.retail.v2alpha.SearchService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async", + "title": "CatalogService createServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a FAILED_PRECONDITION error is returned.", + "canonical": true, + "file": "serving_config_service.create_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "serving_config", + "type": ".google.cloud.retail.v2alpha.ServingConfig" + }, + { + "name": "serving_config_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async", + "title": "CatalogService deleteServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.delete_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async", + "title": "CatalogService updateServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates a ServingConfig.", + "canonical": true, + "file": "serving_config_service.update_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": ".google.cloud.retail.v2alpha.ServingConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_GetServingConfig_async", + "title": "CatalogService getServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.get_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async", + "title": "CatalogService listServingConfigs Sample", + "origin": "API_DEFINITION", + "description": " Lists all ServingConfigs linked to this catalog.", + "canonical": true, + "file": "serving_config_service.list_serving_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListServingConfigsResponse", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_AddControl_async", + "title": "CatalogService addControl Sample", + "origin": "API_DEFINITION", + "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", + "canonical": true, + "file": "serving_config_service.add_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_RemoveControl_async", + "title": "CatalogService removeControl Sample", + "origin": "API_DEFINITION", + "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", + "canonical": true, + "file": "serving_config_service.remove_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_WriteUserEvent_async", + "title": "CatalogService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2alpha.UserEvent" + } + ], + "resultType": ".google.cloud.retail.v2alpha.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_CollectUserEvent_async", + "title": "CatalogService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_PurgeUserEvents_async", + "title": "CatalogService purgeUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", + "canonical": true, + "file": "user_event_service.purge_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 83, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_ImportUserEvents_async", + "title": "CatalogService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2alpha.UserEventInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_RejoinUserEvents_async", + "title": "CatalogService rejoinUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", + "canonical": true, + "file": "user_event_service.rejoin_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event_rejoin_scope", + "type": ".google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js new file mode 100644 index 00000000..2c259bbf --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2alpha_generated_UserEventService_CollectUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + */ + // const userEvent = 'abc123' + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + */ + // const uri = 'abc123' + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + */ + // const ets = 1234 + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END retail_v2alpha_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js new file mode 100644 index 00000000..733e1b2f --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2alpha_generated_UserEventService_ImportUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. `projects/1234/locations/global/catalogs/default_catalog` + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorsConfig = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END retail_v2alpha_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js new file mode 100644 index 00000000..9d1d604c --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js @@ -0,0 +1,91 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * * `eventType`: Double quoted + * UserEvent.event_type google.cloud.retail.v2alpha.UserEvent.event_type + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * Examples: + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * The filtering fields are assumed to have an implicit AND. + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + */ + // const force = true + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callPurgeUserEvents() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeUserEvents(); + // [END retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000..e72b2378 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + */ + // const userEventRejoinScope = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callRejoinUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await retailClient.rejoinUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRejoinUserEvents(); + // [END retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js new file mode 100644 index 00000000..8742b980 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2alpha_generated_UserEventService_WriteUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END retail_v2alpha_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/src/index.ts b/owl-bot-staging/v2alpha/src/index.ts new file mode 100644 index 00000000..ebdb9c41 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/index.ts @@ -0,0 +1,39 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 v2alpha from './v2alpha'; +const CatalogServiceClient = v2alpha.CatalogServiceClient; +type CatalogServiceClient = v2alpha.CatalogServiceClient; +const CompletionServiceClient = v2alpha.CompletionServiceClient; +type CompletionServiceClient = v2alpha.CompletionServiceClient; +const ControlServiceClient = v2alpha.ControlServiceClient; +type ControlServiceClient = v2alpha.ControlServiceClient; +const PredictionServiceClient = v2alpha.PredictionServiceClient; +type PredictionServiceClient = v2alpha.PredictionServiceClient; +const ProductServiceClient = v2alpha.ProductServiceClient; +type ProductServiceClient = v2alpha.ProductServiceClient; +const SearchServiceClient = v2alpha.SearchServiceClient; +type SearchServiceClient = v2alpha.SearchServiceClient; +const ServingConfigServiceClient = v2alpha.ServingConfigServiceClient; +type ServingConfigServiceClient = v2alpha.ServingConfigServiceClient; +const UserEventServiceClient = v2alpha.UserEventServiceClient; +type UserEventServiceClient = v2alpha.UserEventServiceClient; +export {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +export default {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts new file mode 100644 index 00000000..c1af21ae --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts @@ -0,0 +1,1865 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/catalog_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './catalog_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for managing catalog configuration. + * @class + * @memberof v2alpha + */ +export class CatalogServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + catalogServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CatalogServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CatalogServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listCatalogs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.CatalogService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.catalogServiceStub) { + return this.catalogServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.CatalogService. + this.catalogServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.CatalogService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.CatalogService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const catalogServiceStubMethods = + ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch', 'getCompletionConfig', 'updateCompletionConfig', 'getAttributesConfig', 'updateAttributesConfig', 'addCatalogAttribute', 'removeCatalogAttribute', 'replaceCatalogAttribute']; + for (const methodName of catalogServiceStubMethods) { + const callPromise = this.catalogServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.catalogServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Updates the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Catalog} request.catalog + * Required. The {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update does not + * exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.update_catalog.js + * region_tag:retail_v2alpha_generated_CatalogService_UpdateCatalog_async + */ + updateCatalog( + request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|undefined, {}|undefined + ]>; + updateCatalog( + request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog.name': request.catalog!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCatalog(request, options, callback); + } +/** + * Set a specified branch id as default branch. API methods such as + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search}, + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct}, + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as + * default, setting + * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` + * as {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} + * to route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.branchId + * The final component of the resource name of a branch. + * + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * + * If there are no sufficient active products in the targeted branch and + * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.force|force} is not + * set, a FAILED_PRECONDITION error is returned. + * @param {string} request.note + * Some note on this request, this can be retrieved by + * {@link google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} + * before next valid default branch set occurs. + * + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {boolean} request.force + * If set to true, it permits switching to a branch with + * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id|branch_id} + * even if it has no sufficient active products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.set_default_branch.js + * region_tag:retail_v2alpha_generated_CatalogService_SetDefaultBranch_async + */ + setDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|undefined, {}|undefined + ]>; + setDefaultBranch( + request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultBranch(request, options, callback); + } +/** + * Get which branch is currently default branch set by + * {@link google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} + * method under a specified parent catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2alpha.GetDefaultBranchResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.get_default_branch.js + * region_tag:retail_v2alpha_generated_CatalogService_GetDefaultBranch_async + */ + getDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|undefined, {}|undefined + ]>; + getDefaultBranch( + request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.get_completion_config.js + * region_tag:retail_v2alpha_generated_CatalogService_GetCompletionConfig_async + */ + getCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|undefined, {}|undefined + ]>; + getCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getCompletionConfig(request, options, callback); + } +/** + * Updates the + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.CompletionConfig} request.completionConfig + * Required. The + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to + * update does not exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. + * The following are the only supported fields: + * + * * {@link google.cloud.retail.v2alpha.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link google.cloud.retail.v2alpha.CompletionConfig.auto_learning|CompletionConfig.auto_learning} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.update_completion_config.js + * region_tag:retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async + */ + updateCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|undefined, {}|undefined + ]>; + updateCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'completion_config.name': request.completionConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCompletionConfig(request, options, callback); + } +/** + * Gets an {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.get_attributes_config.js + * region_tag:retail_v2alpha_generated_CatalogService_GetAttributesConfig_async + */ + getAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|undefined, {}|undefined + ]>; + getAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getAttributesConfig(request, options, callback); + } +/** + * Updates the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * The catalog attributes in the request will be updated in the catalog, or + * inserted if they do not exist. Existing catalog attributes not included in + * the request will remain unchanged. Attributes that are assigned to + * products, but do not exist at the catalog level, are always included in the + * response. The product attribute is assigned default values for missing + * catalog attribute fields, e.g., searchable and dynamic facetable options. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.AttributesConfig} request.attributesConfig + * Required. The + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. + * The following is the only supported field: + * + * * {@link google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.update_attributes_config.js + * region_tag:retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async + */ + updateAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|undefined, {}|undefined + ]>; + updateAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config.name': request.attributesConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateAttributesConfig(request, options, callback); + } +/** + * Adds the specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to + * add already exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute + * Required. The + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to add. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.add_catalog_attribute.js + * region_tag:retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async + */ + addCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|undefined, {}|undefined + ]>; + addCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.addCatalogAttribute(request, options, callback); + } +/** + * Removes the specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} from the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to + * remove does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {string} request.key + * Required. The attribute name key of the + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to remove. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js + * region_tag:retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async + */ + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|undefined, {}|undefined + ]>; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute(request, options, callback); + } +/** + * Replaces the specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} in the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} by + * updating the catalog attribute with the same + * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to + * replace does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute + * Required. The updated + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to update. + * The following are NOT supported: + * + * * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js + * region_tag:retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async + */ + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|undefined, {}|undefined + ]>; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.replaceCatalogAttribute(request, options, callback); + } + + /** + * Lists all the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s associated + * with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogs( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICatalog[], + protos.google.cloud.retail.v2alpha.IListCatalogsRequest|null, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse + ]>; + listCatalogs( + request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.ICatalog>): void; + listCatalogs( + request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.ICatalog>): void; + listCatalogs( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.ICatalog>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.ICatalog>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICatalog[], + protos.google.cloud.retail.v2alpha.IListCatalogsRequest|null, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listCatalogs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2alpha.Catalog} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogsStream( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.createStream( + this.innerApiCalls.listCatalogs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCatalogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.list_catalogs.js + * region_tag:retail_v2alpha_generated_CatalogService_ListCatalogs_async + */ + listCatalogsAsync( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.asyncIterate( + this.innerApiCalls['listCatalogs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.catalogServiceStub && !this._terminated) { + return this.catalogServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json new file mode 100644 index 00000000..08407daa --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json @@ -0,0 +1,90 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.CatalogService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListCatalogs": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCatalog": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "SetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "AddCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "RemoveCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ReplaceCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts new file mode 100644 index 00000000..36be33c4 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts @@ -0,0 +1,936 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Auto-completion service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2alpha + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importCompletionDataResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportCompletionDataResponse') as gax.protobuf.Type; + const importCompletionDataMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importCompletionData: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importCompletionDataResponse.decode.bind(importCompletionDataResponse), + importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.CompletionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.CompletionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.CompletionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const completionServiceStubMethods = + ['completeQuery', 'importCompletionData']; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Required. Catalog for which the completion is performed. + * + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string} request.visitorId + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {string[]} request.languageCodes + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see [Tags for + * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + * @param {string} request.deviceType + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * + * Supported formats: + * + * * `UNKNOWN_DEVICE_TYPE` + * + * * `DESKTOP` + * + * * `MOBILE` + * + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + * @param {string} request.dataset + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * {@link google.cloud.retail.v2alpha.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * + * Current supported values: + * + * * user-data + * + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + * @param {number} request.maxSuggestions + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. + * + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2alpha.CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/completion_service.complete_query.js + * region_tag:retail_v2alpha_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|undefined, {}|undefined + ]>; + completeQuery( + request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + +/** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog which the suggestions dataset belongs to. + * + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2alpha.CompletionDataInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js + * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async + */ + importCompletionData( + request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importCompletionData( + request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importCompletionData(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importCompletionData()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js + * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async + */ + async checkImportCompletionDataProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json new file mode 100644 index 00000000..ac2795a5 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json @@ -0,0 +1,45 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.CompletionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ImportCompletionData": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts new file mode 100644 index 00000000..bef33ee7 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts @@ -0,0 +1,1195 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/control_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './control_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for modifying Control. + * @class + * @memberof v2alpha + */ +export class ControlServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + controlServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ControlServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ControlServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listControls: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'controls') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.ControlService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.controlServiceStub) { + return this.controlServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ControlService. + this.controlServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ControlService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ControlService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const controlServiceStubMethods = + ['createControl', 'deleteControl', 'updateControl', 'getControl', 'listControls']; + for (const methodName of controlServiceStubMethods) { + const callPromise = this.controlServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.controlServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a Control. + * + * If the {@link google.cloud.retail.v2alpha.Control|Control} to create already + * exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent catalog. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {google.cloud.retail.v2alpha.Control} request.control + * Required. The Control to create. + * @param {string} request.controlId + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.create_control.js + * region_tag:retail_v2alpha_generated_ControlService_CreateControl_async + */ + createControl( + request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|undefined, {}|undefined + ]>; + createControl( + request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createControl(request, options, callback); + } +/** + * Deletes a Control. + * + * If the {@link google.cloud.retail.v2alpha.Control|Control} to delete does not + * exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.delete_control.js + * region_tag:retail_v2alpha_generated_ControlService_DeleteControl_async + */ + deleteControl( + request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|undefined, {}|undefined + ]>; + deleteControl( + request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteControl(request, options, callback); + } +/** + * Updates a Control. + * + * {@link google.cloud.retail.v2alpha.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link google.cloud.retail.v2alpha.Control|Control} to delete does not exist, a + * NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Control} request.control + * Required. The Control to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.Control|Control} to update. The following are + * NOT supported: + * + * * {@link google.cloud.retail.v2alpha.Control.name|Control.name} + * + * If not set or empty, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.update_control.js + * region_tag:retail_v2alpha_generated_ControlService_UpdateControl_async + */ + updateControl( + request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|undefined, {}|undefined + ]>; + updateControl( + request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'control.name': request.control!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateControl(request, options, callback); + } +/** + * Gets a Control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.get_control.js + * region_tag:retail_v2alpha_generated_ControlService_GetControl_async + */ + getControl( + request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|undefined, {}|undefined + ]>; + getControl( + request: protos.google.cloud.retail.v2alpha.IGetControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request: protos.google.cloud.retail.v2alpha.IGetControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Control]{@link google.cloud.retail.v2alpha.Control}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControls( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl[], + protos.google.cloud.retail.v2alpha.IListControlsRequest|null, + protos.google.cloud.retail.v2alpha.IListControlsResponse + ]>; + listControls( + request: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IControl>): void; + listControls( + request: protos.google.cloud.retail.v2alpha.IListControlsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IControl>): void; + listControls( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IControl>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IControl>): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl[], + protos.google.cloud.retail.v2alpha.IListControlsRequest|null, + protos.google.cloud.retail.v2alpha.IListControlsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listControls(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Control]{@link google.cloud.retail.v2alpha.Control} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControlsStream( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.createStream( + this.innerApiCalls.listControls as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listControls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Control]{@link google.cloud.retail.v2alpha.Control}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.list_controls.js + * region_tag:retail_v2alpha_generated_ControlService_ListControls_async + */ + listControlsAsync( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.asyncIterate( + this.innerApiCalls['listControls'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.controlServiceStub && !this._terminated) { + return this.controlServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json new file mode 100644 index 00000000..9a86d786 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ControlService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListControls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json b/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json new file mode 100644 index 00000000..aeabbe19 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json @@ -0,0 +1,581 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.retail.v2alpha", + "libraryPackage": "@google-cloud/retail", + "services": { + "CatalogService": { + "clients": { + "grpc": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + } + } + }, + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + } + } + }, + "ControlService": { + "clients": { + "grpc": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "ProductService": { + "clients": { + "grpc": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "ServingConfigService": { + "clients": { + "grpc": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/index.ts b/owl-bot-staging/v2alpha/src/v2alpha/index.ts new file mode 100644 index 00000000..a7e4f6ba --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/index.ts @@ -0,0 +1,26 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CatalogServiceClient} from './catalog_service_client'; +export {CompletionServiceClient} from './completion_service_client'; +export {ControlServiceClient} from './control_service_client'; +export {PredictionServiceClient} from './prediction_service_client'; +export {ProductServiceClient} from './product_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {ServingConfigServiceClient} from './serving_config_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts new file mode 100644 index 00000000..6a5d9153 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts @@ -0,0 +1,837 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/prediction_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './prediction_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for making recommendation prediction. + * @class + * @memberof v2alpha + */ +export class PredictionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + predictionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PredictionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PredictionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.PredictionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.predictionServiceStub) { + return this.predictionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.PredictionService. + this.predictionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.PredictionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.PredictionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const predictionServiceStubMethods = + ['predict']; + for (const methodName of predictionServiceStubMethods) { + const callPromise = this.predictionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.predictionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Makes a recommendation prediction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see [Managing + * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * @param {number} request.pageSize + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * @param {string} request.pageToken + * The previous PredictResponse.next_page_token. + * @param {string} request.filter + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * + * Examples: + * + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * @param {boolean} request.validateOnly + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the predictions. + * + * Allowed values: + * + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2alpha.PredictResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/prediction_service.predict.js + * region_tag:retail_v2alpha_generated_PredictionService_Predict_async + */ + predict( + request?: protos.google.cloud.retail.v2alpha.IPredictRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|undefined, {}|undefined + ]>; + predict( + request: protos.google.cloud.retail.v2alpha.IPredictRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request: protos.google.cloud.retail.v2alpha.IPredictRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request?: protos.google.cloud.retail.v2alpha.IPredictRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.predictionServiceStub && !this._terminated) { + return this.predictionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json new file mode 100644 index 00000000..ed48fe50 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.PredictionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts new file mode 100644 index 00000000..0d593a5e --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts @@ -0,0 +1,2641 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/product_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.retail.v2alpha.Product|Product} + * information of the customer's website. + * @class + * @memberof v2alpha + */ +export class ProductServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProductServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeProductsResponse') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeProductsMetadata') as gax.protobuf.Type; + const importProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportProductsResponse') as gax.protobuf.Type; + const importProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; + const setInventoryResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.SetInventoryResponse') as gax.protobuf.Type; + const setInventoryMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.SetInventoryMetadata') as gax.protobuf.Type; + const addFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse') as gax.protobuf.Type; + const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; + const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; + const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; + const addLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddLocalInventoriesResponse') as gax.protobuf.Type; + const addLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata') as gax.protobuf.Type; + const removeLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse') as gax.protobuf.Type; + const removeLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)), + importProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductsResponse.decode.bind(importProductsResponse), + importProductsMetadata.decode.bind(importProductsMetadata)), + setInventory: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInventoryResponse.decode.bind(setInventoryResponse), + setInventoryMetadata.decode.bind(setInventoryMetadata)), + addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), + addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), + removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), + removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), + addLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), + addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), + removeLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), + removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.ProductService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.productServiceStub) { + return this.productServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ProductService. + this.productServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ProductService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ProductService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const productServiceStubMethods = + ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'purgeProducts', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; + for (const methodName of productServiceStubMethods) { + const callPromise = this.productServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.productServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + * @param {google.cloud.retail.v2alpha.Product} request.product + * Required. The {@link google.cloud.retail.v2alpha.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the + * {@link google.cloud.retail.v2alpha.Product|Product}, which will become the final + * component of the {@link google.cloud.retail.v2alpha.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * This field must be unique among all + * {@link google.cloud.retail.v2alpha.Product|Product}s with the same + * {@link google.cloud.retail.v2alpha.CreateProductRequest.parent|parent}. + * Otherwise, an ALREADY_EXISTS error is returned. + * + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.create_product.js + * region_tag:retail_v2alpha_generated_ProductService_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link google.cloud.retail.v2alpha.Product|Product} does not + * exist, a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.get_product.js + * region_tag:retail_v2alpha_generated_ProductService_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.retail.v2alpha.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.retail.v2alpha.IGetProductRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Updates a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Product} request.product + * Required. The product to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not + * exist and + * {@link google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing|allow_missing} + * is not set, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.Product|Product} to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, a new {@link google.cloud.retail.v2alpha.Product|Product} will be + * created. In this situation, `update_mask` is ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.update_product.js + * region_tag:retail_v2alpha_generated_ProductService_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Deletes a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to delete does not + * exist, a NOT_FOUND error is returned. + * + * The {@link google.cloud.retail.v2alpha.Product|Product} to delete can neither be + * a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} member nor a + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} with more than one + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link google.cloud.retail.v2alpha.Product|Product} will be deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.delete_product.js + * region_tag:retail_v2alpha_generated_ProductService_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } + +/** + * Permanently deletes all selected + * {@link google.cloud.retail.v2alpha.Product|Product}s under a branch. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed offline. Depending on the number of + * {@link google.cloud.retail.v2alpha.Product|Product}s, this operation could take + * hours to complete. Before the operation completes, some + * {@link google.cloud.retail.v2alpha.Product|Product}s may still be returned by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * Depending on the number of {@link google.cloud.retail.v2alpha.Product|Product}s, + * this operation could take hours to complete. To get a sample of + * {@link google.cloud.retail.v2alpha.Product|Product}s that would be deleted, set + * {@link google.cloud.retail.v2alpha.PurgeProductsRequest.force|PurgeProductsRequest.force} + * to false. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the branch under which the products are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` + * @param {string} request.filter + * Required. The filter string to specify the products to be deleted with a + * length limit of 5,000 characters. + * + * Empty string filter is not allowed. "*" implies delete all items in a + * branch. + * + * The eligible fields for filtering are: + * + * * `availability`: Double quoted + * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} + * string. + * * `create_time` : in ISO 8601 "zulu" format. + * + * Supported syntax: + * + * * Comparators (">", "<", ">=", "<=", "="). + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" + * * availability = "IN_STOCK" + * + * * Conjunctions ("AND") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" + * + * * Disjunctions ("OR") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" + * + * * Can support nested queries. + * Examples: + * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") + * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") + * + * * Filter Limits: + * * Filter should not contain more than 6 conditions. + * * Max nesting depth should not exceed 2 levels. + * + * Examples queries: + * * Delete back order products created before a timestamp. + * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.purge_products.js + * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.retail.v2alpha.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' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.purge_products.js + * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async + */ + async checkPurgeProductsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeProducts, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Bulk import of multiple {@link google.cloud.retail.v2alpha.Product|Product}s. + * + * Request processing may be synchronous. No partial updating is supported. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * {@link google.cloud.retail.v2alpha.Product|Product}s to be successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + * @param {string} request.requestId + * Deprecated. This field has no effect. + * @param {google.cloud.retail.v2alpha.ProductInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + * @param {google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * {@link google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * + * Only supported when + * {@link google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} + * is set to `FULL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.import_products.js + * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async + */ + importProducts( + request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProducts( + request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.import_products.js + * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async + */ + async checkImportProductsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates inventory information for a + * {@link google.cloud.retail.v2alpha.Product|Product} while respecting the last + * update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, updates are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct}, + * the specified inventory field value(s) will overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update time for the specified inventory fields will be overwritten to the + * time of the + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2alpha.CreateProductRequest.product|CreateProductRequest.product}, + * then any pre-existing inventory information for this product will be used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information will be preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2alpha.ProductService.SetInventory|SetInventory}, + * {@link google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Product} request.inventory + * Required. The inventory information to update. The allowable fields to + * update are: + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.Product|Product} named in + * {@link google.cloud.retail.v2alpha.Product.name|Product.name}, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to update has + * existing inventory information, the provided inventory information will be + * merged while respecting the last update time for each inventory field, + * using the provided or default value for + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. + * + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} + * + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link |SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} + * + * The last update time is recorded for the following inventory fields: + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, {@link |UpdateProduct} should be invoked instead. + * @param {google.protobuf.FieldMask} request.setMask + * Indicates which inventory fields in the provided + * {@link google.cloud.retail.v2alpha.Product|Product} to update. + * + * At least one field must be provided. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.setTime + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} with + * name {@link google.cloud.retail.v2alpha.Product.name|Product.name} is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the {@link google.cloud.retail.v2alpha.Product|Product} is created. If set + * to false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.set_inventory.js + * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async + */ + setInventory( + request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInventory( + request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'inventory.name': request.inventory!.name || '', + }); + this.initialize(); + return this.innerApiCalls.setInventory(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInventory()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.set_inventory.js + * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async + */ + async checkSetInventoryProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally adds place IDs to + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}. + * Duplicate IDs will be automatically ignored. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * If the total number of place IDs exceeds 2000 for this + * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type} after + * adding, then the update will be rejected. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async + */ + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async + */ + async checkAddFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally removes place IDs from a + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async + */ + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async + */ + async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates local inventory information for a + * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {number[]} request.localInventories + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + * @param {google.protobuf.FieldMask} request.addMask + * Indicates which inventory fields in the provided list of + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory} to update. The + * field is updated to the provided value. + * + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async + */ + addLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addLocalInventories( + request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async + */ + async checkAddLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Remove local inventory information for a + * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places at a + * removal timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {string[]} request.placeIds + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async + */ + removeLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeLocalInventories( + request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async + */ + async checkRemoveLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.retail.v2alpha.Product|Product}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} or + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.requireTotalSize + * If true and + * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} + * is set to the total count of matched items irrespective of pagination. + * + * Notice that setting this field to true affects the performance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.retail.v2alpha.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct[], + protos.google.cloud.retail.v2alpha.IListProductsRequest|null, + protos.google.cloud.retail.v2alpha.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IProduct>): void; + listProducts( + request: protos.google.cloud.retail.v2alpha.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IProduct>): void; + listProducts( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IProduct>): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct[], + protos.google.cloud.retail.v2alpha.IListProductsRequest|null, + protos.google.cloud.retail.v2alpha.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} or + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.requireTotalSize + * If true and + * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} + * is set to the total count of matched items irrespective of pagination. + * + * Notice that setting this field to true affects the performance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2alpha.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} or + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.requireTotalSize + * If true and + * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} + * is set to the total count of matched items irrespective of pagination. + * + * Notice that setting this field to true affects the performance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.retail.v2alpha.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.list_products.js + * region_tag:retail_v2alpha_generated_ProductService_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.productServiceStub && !this._terminated) { + return this.productServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json new file mode 100644 index 00000000..416ef1ec --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json @@ -0,0 +1,104 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ProductService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "GetProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ListProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "UpdateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "DeleteProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "PurgeProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportProducts": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "SetInventory": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts new file mode 100644 index 00000000..5e93921a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts @@ -0,0 +1,1537 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2alpha + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + search: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.SearchService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.SearchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.SearchService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const searchServiceStubMethods = + ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold + * The relevance threshold of the search results. + * + * Defaults to + * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2alpha.ISearchRequest|null, + protos.google.cloud.retail.v2alpha.ISearchResponse + ]>; + search( + request: protos.google.cloud.retail.v2alpha.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): void; + search( + request: protos.google.cloud.retail.v2alpha.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): void; + search( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): + Promise<[ + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2alpha.ISearchRequest|null, + protos.google.cloud.retail.v2alpha.ISearchResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold + * The relevance threshold of the search results. + * + * Defaults to + * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `search`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold + * The relevance threshold of the search results. + * + * Defaults to + * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/search_service.search.js + * region_tag:retail_v2alpha_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json new file mode 100644 index 00000000..71a5a478 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.SearchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts new file mode 100644 index 00000000..1df816d8 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts @@ -0,0 +1,1334 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/serving_config_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './serving_config_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for modifying ServingConfig. + * @class + * @memberof v2alpha + */ +export class ServingConfigServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + servingConfigServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServingConfigServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServingConfigServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listServingConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'servingConfigs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.ServingConfigService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.servingConfigServiceStub) { + return this.servingConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ServingConfigService. + this.servingConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ServingConfigService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ServingConfigService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const servingConfigServiceStubMethods = + ['createServingConfig', 'deleteServingConfig', 'updateServingConfig', 'getServingConfig', 'listServingConfigs', 'addControl', 'removeControl']; + for (const methodName of servingConfigServiceStubMethods) { + const callPromise = this.servingConfigServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.servingConfigServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a ServingConfig. + * + * A maximum of 100 + * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig}s are allowed in + * a {@link google.cloud.retail.v2alpha.Catalog|Catalog}, otherwise a + * FAILED_PRECONDITION error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig + * Required. The ServingConfig to create. + * @param {string} request.servingConfigId + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.create_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async + */ + createServingConfig( + request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|undefined, {}|undefined + ]>; + createServingConfig( + request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createServingConfig(request, options, callback); + } +/** + * Deletes a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.delete_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async + */ + deleteServingConfig( + request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|undefined, {}|undefined + ]>; + deleteServingConfig( + request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteServingConfig(request, options, callback); + } +/** + * Updates a ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig + * Required. The ServingConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2alpha.ServingConfig.name|ServingConfig.name} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.update_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async + */ + updateServingConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|undefined, {}|undefined + ]>; + updateServingConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config.name': request.servingConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateServingConfig(request, options, callback); + } +/** + * Gets a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.get_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_GetServingConfig_async + */ + getServingConfig( + request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|undefined, {}|undefined + ]>; + getServingConfig( + request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getServingConfig(request, options, callback); + } +/** + * Enables a Control on the specified ServingConfig. + * The control is added in the last position of the list of controls + * it belongs to (e.g. if it's a facet spec control it will be applied + * in the last position of servingConfig.facetSpecIds) + * Returns a ALREADY_EXISTS error if the control has already been applied. + * Returns a FAILED_PRECONDITION error if the addition could exceed maximum + * number of control allowed for that type of control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.add_control.js + * region_tag:retail_v2alpha_generated_ServingConfigService_AddControl_async + */ + addControl( + request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|undefined, {}|undefined + ]>; + addControl( + request: protos.google.cloud.retail.v2alpha.IAddControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request: protos.google.cloud.retail.v2alpha.IAddControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config': request.servingConfig || '', + }); + this.initialize(); + return this.innerApiCalls.addControl(request, options, callback); + } +/** + * Disables a Control on the specified ServingConfig. + * The control is removed from the ServingConfig. + * Returns a NOT_FOUND error if the Control is not enabled for the + * ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.remove_control.js + * region_tag:retail_v2alpha_generated_ServingConfigService_RemoveControl_async + */ + removeControl( + request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|undefined, {}|undefined + ]>; + removeControl( + request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config': request.servingConfig || '', + }); + this.initialize(); + return this.innerApiCalls.removeControl(request, options, callback); + } + + /** + * Lists all ServingConfigs linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigs( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig[], + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + ]>; + listServingConfigs( + request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IServingConfig>): void; + listServingConfigs( + request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IServingConfig>): void; + listServingConfigs( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IServingConfig>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IServingConfig>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig[], + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listServingConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigsStream( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.createStream( + this.innerApiCalls.listServingConfigs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServingConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.list_serving_configs.js + * region_tag:retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async + */ + listServingConfigsAsync( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.asyncIterate( + this.innerApiCalls['listServingConfigs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.servingConfigServiceStub && !this._terminated) { + return this.servingConfigServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json new file mode 100644 index 00000000..6489c5db --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ServingConfigService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServingConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts new file mode 100644 index 00000000..bde84f81 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts @@ -0,0 +1,1201 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on the customer website. + * @class + * @memberof v2alpha + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const purgeUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeUserEventsResponse') as gax.protobuf.Type; + const purgeUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeMetadata') as gax.protobuf.Type; + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportUserEventsResponse') as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; + const rejoinUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RejoinUserEventsResponse') as gax.protobuf.Type; + const rejoinUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RejoinUserEventsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), + purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata)), + rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), + rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.UserEventService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.UserEventService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.UserEventService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const userEventServiceStubMethods = + ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2alpha.UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.write_user_event.js + * region_tag:retail_v2alpha_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|undefined, {}|undefined + ]>; + writeUserEvent( + request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } +/** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.collect_user_event.js + * region_tag:retail_v2alpha_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|undefined, {}|undefined + ]>; + collectUserEvent( + request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + +/** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + * @param {string} request.filter + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * + * * `eventType`: Double quoted + * {@link google.cloud.retail.v2alpha.UserEvent.event_type|UserEvent.event_type} + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * + * Examples: + * + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * + * The filtering fields are assumed to have an implicit AND. + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async + */ + purgeUserEvents( + request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeUserEvents( + request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.purgeUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async + */ + async checkPurgeUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. `projects/1234/locations/global/catalogs/default_catalog` + * @param {google.cloud.retail.v2alpha.UserEventInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importUserEvents( + request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a user event rejoin operation with latest product catalog. Events + * will not be annotated with detailed product information if product is + * missing from the catalog at the time the user event is ingested, and these + * events are stored as unjoined events with a limited usage on training and + * serving. This method can be used to start a join operation on specified + * events with latest version of product catalog. It can also be used to + * correct events joined with the wrong product catalog. A rejoin operation + * can take hours or days to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async + */ + rejoinUserEvents( + request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rejoinUserEvents( + request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.rejoinUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rejoinUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async + */ + async checkRejoinUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json new file mode 100644 index 00000000..21dfac2e --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.UserEventService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "CollectUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "PurgeUserEvents": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportUserEvents": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "RejoinUserEvents": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..57b7c7be --- /dev/null +++ b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js @@ -0,0 +1,34 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const retail = require('@google-cloud/retail'); + +function main() { + const catalogServiceClient = new retail.CatalogServiceClient(); + const completionServiceClient = new retail.CompletionServiceClient(); + const controlServiceClient = new retail.ControlServiceClient(); + const predictionServiceClient = new retail.PredictionServiceClient(); + const productServiceClient = new retail.ProductServiceClient(); + const searchServiceClient = new retail.SearchServiceClient(); + const servingConfigServiceClient = new retail.ServingConfigServiceClient(); + const userEventServiceClient = new retail.UserEventServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..25eaae42 --- /dev/null +++ b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts @@ -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. ** + +import {CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient} from '@google-cloud/retail'; + +// check that the client class type name can be used +function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { + client.close(); +} +function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { + client.close(); +} +function doStuffWithControlServiceClient(client: ControlServiceClient) { + client.close(); +} +function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { + client.close(); +} +function doStuffWithProductServiceClient(client: ProductServiceClient) { + client.close(); +} +function doStuffWithSearchServiceClient(client: SearchServiceClient) { + client.close(); +} +function doStuffWithServingConfigServiceClient(client: ServingConfigServiceClient) { + client.close(); +} +function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const catalogServiceClient = new CatalogServiceClient(); + doStuffWithCatalogServiceClient(catalogServiceClient); + // check that the client instance can be created + const completionServiceClient = new CompletionServiceClient(); + doStuffWithCompletionServiceClient(completionServiceClient); + // check that the client instance can be created + const controlServiceClient = new ControlServiceClient(); + doStuffWithControlServiceClient(controlServiceClient); + // check that the client instance can be created + const predictionServiceClient = new PredictionServiceClient(); + doStuffWithPredictionServiceClient(predictionServiceClient); + // check that the client instance can be created + const productServiceClient = new ProductServiceClient(); + doStuffWithProductServiceClient(productServiceClient); + // check that the client instance can be created + const searchServiceClient = new SearchServiceClient(); + doStuffWithSearchServiceClient(searchServiceClient); + // check that the client instance can be created + const servingConfigServiceClient = new ServingConfigServiceClient(); + doStuffWithServingConfigServiceClient(servingConfigServiceClient); + // check that the client instance can be created + const userEventServiceClient = new UserEventServiceClient(); + doStuffWithUserEventServiceClient(userEventServiceClient); +} + +main(); diff --git a/owl-bot-staging/v2alpha/system-test/install.ts b/owl-bot-staging/v2alpha/system-test/install.ts new file mode 100644 index 00000000..8ec45222 --- /dev/null +++ b/owl-bot-staging/v2alpha/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/v2alpha/test/gapic_catalog_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts new file mode 100644 index 00000000..017ab407 --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts @@ -0,0 +1,1790 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as catalogserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.CatalogServiceClient', () => { + it('has servicePath', () => { + const servicePath = catalogserviceModule.v2alpha.CatalogServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = catalogserviceModule.v2alpha.CatalogServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = catalogserviceModule.v2alpha.CatalogServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + await client.initialize(); + assert(client.catalogServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.catalogServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('updateCatalog', () => { + it('invokes updateCatalog without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); + const [response] = await client.updateCatalog(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCatalog( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICatalog|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCatalog with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCatalog(request), expectedError); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCatalog(request), expectedError); + }); + }); + + describe('setDefaultBranch', () => { + it('invokes setDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultBranch( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultBranch(request), expectedError); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultBranch(request), expectedError); + }); + }); + + describe('getDefaultBranch', () => { + it('invokes getDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.getDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDefaultBranch( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDefaultBranch(request), expectedError); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDefaultBranch(request), expectedError); + }); + }); + + describe('getCompletionConfig', () => { + it('invokes getCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); + client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCompletionConfig(request), expectedError); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCompletionConfig(request), expectedError); + }); + }); + + describe('updateCompletionConfig', () => { + it('invokes updateCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); + client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + }); + }); + + describe('getAttributesConfig', () => { + it('invokes getAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAttributesConfig(request), expectedError); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAttributesConfig(request), expectedError); + }); + }); + + describe('updateAttributesConfig', () => { + it('invokes updateAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + }); + }); + + describe('addCatalogAttribute', () => { + it('invokes addCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.addCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + }); + }); + + describe('removeCatalogAttribute', () => { + it('invokes removeCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.removeCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + }); + }); + + describe('replaceCatalogAttribute', () => { + it('invokes replaceCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.replaceCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes replaceCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.replaceCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes replaceCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes replaceCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + }); + }); + + describe('listCatalogs', () => { + it('invokes listCatalogs without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.listCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogs without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCatalogs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICatalog[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCatalogs with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCatalogs(request), expectedError); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogsStream without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCatalogsStream with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; + const iterable = client.listCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts new file mode 100644 index 00000000..c3aba50c --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts @@ -0,0 +1,703 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as completionserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2alpha.CompletionServiceClient', () => { + it('has servicePath', () => { + const servicePath = completionserviceModule.v2alpha.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = completionserviceModule.v2alpha.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v2alpha.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompleteQueryResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('importCompletionData', () => { + it('invokes importCompletionData without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); + const [operation] = await client.importCompletionData(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData without error using callback', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCompletionData( + request, + (err?: Error|null, + result?: LROperation|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.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importCompletionData with call error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importCompletionData(request), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData with LRO error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportCompletionDataProgress without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportCompletionDataProgress with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts new file mode 100644 index 00000000..4f62d30a --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts @@ -0,0 +1,1108 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as controlserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.ControlServiceClient', () => { + it('has servicePath', () => { + const servicePath = controlserviceModule.v2alpha.ControlServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = controlserviceModule.v2alpha.ControlServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = controlserviceModule.v2alpha.ControlServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + await client.initialize(); + assert(client.controlServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.controlServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createControl', () => { + it('invokes createControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); + const [response] = await client.createControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createControl(request), expectedError); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createControl(request), expectedError); + }); + }); + + describe('deleteControl', () => { + it('invokes deleteControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteControl( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteControl(request), expectedError); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteControl(request), expectedError); + }); + }); + + describe('updateControl', () => { + it('invokes updateControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); + const [response] = await client.updateControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateControl(request), expectedError); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateControl(request), expectedError); + }); + }); + + describe('getControl', () => { + it('invokes getControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); + const [response] = await client.getControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getControl(request), expectedError); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getControl(request), expectedError); + }); + }); + + describe('listControls', () => { + it('invokes listControls without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); + const [response] = await client.listControls(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listControls without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listControls( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listControls with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listControls(request), expectedError); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listControlsStream without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.descriptors.page.listControls.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Control) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listControls, request)); + assert.strictEqual( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listControlsStream with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Control) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listControls, request)); + assert.strictEqual( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listControls without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; + const iterable = client.listControlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listControls with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listControlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts new file mode 100644 index 00000000..d449dd3b --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts @@ -0,0 +1,543 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as predictionserviceModule from '../src'; + +import {protobuf} 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('v2alpha.PredictionServiceClient', () => { + it('has servicePath', () => { + const servicePath = predictionserviceModule.v2alpha.PredictionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = predictionserviceModule.v2alpha.PredictionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = predictionserviceModule.v2alpha.PredictionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + await client.initialize(); + assert(client.predictionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.predictionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('predict', () => { + it('invokes predict without error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCall(expectedResponse); + const [response] = await client.predict(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict without error using callback', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.predict( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IPredictResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes predict with error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict with closed client', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); + request.placement = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts new file mode 100644 index 00000000..ad57c1e0 --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts @@ -0,0 +1,2190 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as productserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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('v2alpha.ProductServiceClient', () => { + it('has servicePath', () => { + const servicePath = productserviceModule.v2alpha.ProductServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productserviceModule.v2alpha.ProductServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productserviceModule.v2alpha.ProductServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productserviceModule.v2alpha.ProductServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + await client.initialize(); + assert(client.productServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeProductsRequest()); + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importProducts', () => { + it('invokes importProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProducts( + request, + (err?: Error|null, + result?: LROperation|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.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProducts with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProducts(request), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductsProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductsProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInventory', () => { + it('invokes setInventory without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInventory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInventory( + request, + (err?: Error|null, + result?: LROperation|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.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setInventory with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInventory(request), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkSetInventoryProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInventoryProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInventoryProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addFulfillmentPlaces', () => { + it('invokes addFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeFulfillmentPlaces', () => { + it('invokes removeFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addLocalInventories', () => { + it('invokes addLocalInventories without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.addLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addLocalInventories with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addLocalInventories(request), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeLocalInventories', () => { + it('invokes removeLocalInventories without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeLocalInventories with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeLocalInventories(request), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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.retail.v2alpha.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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.retail.v2alpha.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts new file mode 100644 index 00000000..4c28a3a6 --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts @@ -0,0 +1,770 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.SearchServiceClient', () => { + it('has servicePath', () => { + const servicePath = searchserviceModule.v2alpha.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = searchserviceModule.v2alpha.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v2alpha.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts new file mode 100644 index 00000000..f3a80ec9 --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts @@ -0,0 +1,1302 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as servingconfigserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.ServingConfigServiceClient', () => { + it('has servicePath', () => { + const servicePath = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + await client.initialize(); + assert(client.servingConfigServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servingConfigServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createServingConfig', () => { + it('invokes createServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.createServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createServingConfig(request), expectedError); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createServingConfig(request), expectedError); + }); + }); + + describe('deleteServingConfig', () => { + it('invokes deleteServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServingConfig( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteServingConfig(request), expectedError); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteServingConfig(request), expectedError); + }); + }); + + describe('updateServingConfig', () => { + it('invokes updateServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateServingConfig(request), expectedError); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateServingConfig(request), expectedError); + }); + }); + + describe('getServingConfig', () => { + it('invokes getServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getServingConfig(request), expectedError); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getServingConfig(request), expectedError); + }); + }); + + describe('addControl', () => { + it('invokes addControl without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); + const [response] = await client.addControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addControl with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addControl(request), expectedError); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addControl with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); + request.servingConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addControl(request), expectedError); + }); + }); + + describe('removeControl', () => { + it('invokes removeControl without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); + const [response] = await client.removeControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeControl with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeControl(request), expectedError); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeControl with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); + request.servingConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeControl(request), expectedError); + }); + }); + + describe('listServingConfigs', () => { + it('invokes listServingConfigs without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listServingConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServingConfigs without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServingConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServingConfigs(request), expectedError); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServingConfigsStream without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + ]; + client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listServingConfigsStream with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServingConfigs without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + ]; + client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = []; + const iterable = client.listServingConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServingConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts new file mode 100644 index 00000000..4da29c4b --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts @@ -0,0 +1,1088 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as usereventserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2alpha.UserEventServiceClient', () => { + it('has servicePath', () => { + const servicePath = usereventserviceModule.v2alpha.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = usereventserviceModule.v2alpha.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v2alpha.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IUserEvent|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('purgeUserEvents', () => { + it('invokes purgeUserEvents without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeUserEvents with call error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeUserEvents(request), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rejoinUserEvents', () => { + it('invokes rejoinUserEvents without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.rejoinUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejoinUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes rejoinUserEvents with call error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRejoinUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRejoinUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/tsconfig.json b/owl-bot-staging/v2alpha/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v2alpha/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/v2alpha/webpack.config.js b/owl-bot-staging/v2alpha/webpack.config.js new file mode 100644 index 00000000..f2c58f25 --- /dev/null +++ b/owl-bot-staging/v2alpha/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CatalogService', + filename: './catalog-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v2beta/.eslintignore b/owl-bot-staging/v2beta/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v2beta/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v2beta/.eslintrc.json b/owl-bot-staging/v2beta/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v2beta/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v2beta/.gitignore b/owl-bot-staging/v2beta/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v2beta/.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/v2beta/.jsdoc.js b/owl-bot-staging/v2beta/.jsdoc.js new file mode 100644 index 00000000..19729810 --- /dev/null +++ b/owl-bot-staging/v2beta/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v2beta/.mocharc.js b/owl-bot-staging/v2beta/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v2beta/.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/v2beta/.prettierrc.js b/owl-bot-staging/v2beta/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v2beta/.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/v2beta/README.md b/owl-bot-staging/v2beta/README.md new file mode 100644 index 00000000..822c4573 --- /dev/null +++ b/owl-bot-staging/v2beta/README.md @@ -0,0 +1 @@ +Retail: Nodejs Client diff --git a/owl-bot-staging/v2beta/linkinator.config.json b/owl-bot-staging/v2beta/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v2beta/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/v2beta/package.json b/owl-bot-staging/v2beta/package.json new file mode 100644 index 00000000..94071ee3 --- /dev/null +++ b/owl-bot-staging/v2beta/package.json @@ -0,0 +1,71 @@ +{ + "name": "@google-cloud/retail", + "version": "0.1.0", + "description": "Retail client for Node.js", + "repository": "googleapis/nodejs-retail", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google retail", + "retail", + "catalog service", + "completion service", + "control service", + "prediction service", + "product service", + "search service", + "serving config service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto new file mode 100644 index 00000000..e0b844ef --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto @@ -0,0 +1,397 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configures what level the product should be uploaded with regards to +// how users will be send events and how predictions will be made. +message ProductLevelConfig { + // The type of [Product][google.cloud.retail.v2beta.Product]s allowed to be + // ingested into the catalog. Acceptable values are: + // + // * `primary` (default): You can ingest + // [Product][google.cloud.retail.v2beta.Product]s of all types. When + // ingesting a [Product][google.cloud.retail.v2beta.Product], its type will + // default to + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // if unset. + // * `variant`: You can only ingest + // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s. + // This means + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] + // cannot be empty. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `variant` and + // [merchant_center_product_id_field][google.cloud.retail.v2beta.ProductLevelConfig.merchant_center_product_id_field] + // is `itemGroupId`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string ingestion_product_type = 1; + + // Which field of [Merchant Center + // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be + // imported as [Product.id][google.cloud.retail.v2beta.Product.id]. Acceptable + // values are: + // + // * `offerId` (default): Import `offerId` as the product ID. + // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail + // API will choose one item from the ones with the same `itemGroupId`, and + // use it to represent the item group. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `itemGroupId` and + // [ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] + // is `variant`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string merchant_center_product_id_field = 2; +} + +// Catalog level attribute config for an attribute. For example, if customers +// want to enable/disable facet for a specific attribute. +message CatalogAttribute { + // The type of an attribute. + enum AttributeType { + // The type of the attribute is unknown. + // + // Used when type cannot be derived from attribute that is not + // [in_use][google.cloud.retail.v2beta.CatalogAttribute.in_use]. + UNKNOWN = 0; + + // Textual attribute. + TEXTUAL = 1; + + // Numerical attribute. + NUMERICAL = 2; + } + + // The status of the indexable option of a catalog attribute. + enum IndexableOption { + // Value used when unset. Defaults to + // [INDEXABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. + INDEXABLE_OPTION_UNSPECIFIED = 0; + + // Indexable option enabled for an attribute. + INDEXABLE_ENABLED = 1; + + // Indexable option disabled for an attribute. + INDEXABLE_DISABLED = 2; + } + + // The status of the dynamic facetable option of a catalog attribute. + enum DynamicFacetableOption { + // Value used when unset. Defaults to + // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; + + // Dynamic facetable option enabled for an attribute. + DYNAMIC_FACETABLE_ENABLED = 1; + + // Dynamic facetable option disabled for an attribute. + DYNAMIC_FACETABLE_DISABLED = 2; + } + + // The status of the searchable option of a catalog attribute. + enum SearchableOption { + // Value used when unset. Defaults to + // [SEARCHABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Indicates whether this attribute has been used by any + // products. `True` if at least one + // [Product][google.cloud.retail.v2beta.Product] is using this attribute in + // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. + // Otherwise, this field is `False`. + // + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] can be + // pre-loaded by using [AddCatalogAttribute][], [ImportCatalogAttributes][], + // or [UpdateAttributesConfig][] APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s. + // + // Only [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that + // are not in use by products can be deleted. + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that are + // in use by products cannot be deleted; however, their configuration + // properties will reset to default values upon removal request. + // + // After catalog changes, it takes about 10 minutes for this field to update. + bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The type of this attribute. This is derived from the attribute + // in [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. + AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values + // are indexed so that it can be filtered, faceted, or boosted in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + IndexableOption indexable_option = 5; + + // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic + // facet. Could only be DYNAMIC_FACETABLE_DISABLED if + // [CatalogAttribute.indexable_option][google.cloud.retail.v2beta.CatalogAttribute.indexable_option] + // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. + DynamicFacetableOption dynamic_facetable_option = 6; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values + // are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values + // will not be searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], as + // there are no text values associated to numerical attributes. + SearchableOption searchable_option = 7; +} + +// Catalog level attribute config. +message AttributesConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/AttributesConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }; + + // Required. Immutable. The fully qualified resource name of the attribute + // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Enable attribute(s) config at catalog level. + // For example, indexable, dynamic_facetable, or searchable for each + // attribute. + // + // The key is catalog attribute's name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // + // The maximum number of catalog attributes allowed in a request is 1000. + map catalog_attributes = 2; + + // Output only. The + // [AttributeConfigLevel][google.cloud.retail.v2beta.AttributeConfigLevel] + // used for this catalog. + AttributeConfigLevel attribute_config_level = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Catalog level autocomplete config for customers to customize autocomplete +// feature's settings. +message CompletionConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/CompletionConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }; + + // Required. Immutable. Fully qualified name + // `projects/*/locations/*/catalogs/*/completionConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Specifies the matching order for autocomplete suggestions, e.g., a query + // consisting of 'sh' with 'out-of-order' specified would suggest "women's + // shoes", whereas a query of 'red s' with 'exact-prefix' specified would + // suggest "red shoes". Currently supported values: + // + // * 'out-of-order' + // * 'exact-prefix' + // + // Default value: 'exact-prefix'. + string matching_order = 2; + + // The maximum number of autocomplete suggestions returned per term. The + // maximum allowed max suggestions is 20. Default value is 20. If left unset + // or set to 0, then will fallback to default value. + int32 max_suggestions = 3; + + // The minimum number of characters needed to be typed in order to get + // suggestions. Default value is 2. If left unset or set to 0, then will + // fallback to default value. + int32 min_prefix_length = 4; + + // If set to true, the auto learning function is enabled. Auto learning uses + // user data to generate suggestions using ML techniques. Default value is + // false. Only after enabling auto learning can users use `cloud-retail` + // data in + // [CompleteQueryRequest][google.cloud.retail.v2beta.CompleteQueryRequest]. + bool auto_learning = 11; + + // Output only. The input config for the import of the source data that + // contains the autocomplete phrases uploaded by the customer. + CompletionDataInputConfig suggestions_input_config = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest suggestion terms + // list import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_suggestions_import_operation = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The input config for the import of the source data that + // contains the / autocomplete denylist phrases uploaded by the customer. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. LRO corresponding to the latest denylist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_denylist_import_operation = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The input config for the import of the source data that + // contains the autocomplete allowlist phrases uploaded by the customer. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. LRO corresponding to the latest allowlist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_allowlist_import_operation = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Represents a link between a Merchant Center account and a branch. +// Once a link is established, products from the linked merchant center account +// will be streamed to the linked branch. +message MerchantCenterLink { + // Required. The linked [Merchant center account + // id](https://developers.google.com/shopping-content/guides/accountstatuses). + // The account must be a standalone account or a sub-account of a MCA. + int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch id (e.g. 0/1/2) within this catalog that products from + // merchant_center_account_id are streamed to. When updating this field, an + // empty value will use the currently configured default branch. However, + // changing the default branch later on won't change the linked branch here. + // + // A single branch id can only have one linked merchant center account id. + string branch_id = 2; + + // String representing the destination to import for, all if left empty. + // List of possible values can be found here. + // [https://support.google.com/merchants/answer/7501026] + // List of allowed string values: + // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory + // _ads", "Free_listings", "Free_local_listings" + // NOTE: The string values are case sensitive. + repeated string destinations = 3; + + // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 + // code. List of values can be found + // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) + // under the `region` tag. If left blank no region filtering will be + // performed. + // + // Example value: `US`. + string region_code = 4; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // ISO 639-1. + // + // This specifies the language of offers in Merchant Center that will be + // accepted. If empty no language filtering will be performed. + // + // Example value: `en`. + string language_code = 5; +} + +// Configures Merchant Center linking. +// Links contained in the config will be used to sync data from a Merchant +// Center account to a Cloud Retail branch. +message MerchantCenterLinkingConfig { + // Links between Merchant Center accounts and branches. + repeated MerchantCenterLink links = 1; +} + +// The catalog configuration. +message Catalog { + option (google.api.resource) = { + type: "retail.googleapis.com/Catalog" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" + }; + + // Required. Immutable. The fully qualified resource name of the catalog. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The catalog display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. The product level configuration. + ProductLevelConfig product_level_config = 4 + [(google.api.field_behavior) = REQUIRED]; + + // The Merchant Center linking configuration. + // Once a link is added, the data stream from Merchant Center to Cloud Retail + // will be enabled automatically. The requester must have access to the + // merchant center account in order to make changes to this field. + MerchantCenterLinkingConfig merchant_center_linking_config = 6; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto new file mode 100644 index 00000000..7e27c916 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto @@ -0,0 +1,478 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/catalog.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for managing catalog configuration. +service CatalogService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated + // with the project. + rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*}/catalogs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s. + rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { + option (google.api.http) = { + patch: "/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}" + body: "catalog" + }; + option (google.api.method_signature) = "catalog,update_mask"; + } + + // Set a specified branch id as default branch. API methods such as + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] + // will treat requests using "default_branch" to the actual branch id set as + // default. + // + // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + // default, setting + // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + // to setting + // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/1`. + // + // Using multiple branches can be useful when developers would like + // to have a staging branch to test and verify for future usage. When it + // becomes ready, developers switch on the staging branch using this API while + // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + // as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] + // to route the traffic to this staging branch. + // + // CAUTION: If you have live predict/search traffic, switching the default + // branch could potentially cause outages if the ID space of the new branch is + // very different from the old one. + // + // More specifically: + // + // * PredictionService will only return product IDs from branch {newBranch}. + // * SearchService will only return product IDs from branch {newBranch} + // (if branch is not explicitly set). + // * UserEventService will only join events with products from branch + // {newBranch}. + rpc SetDefaultBranch(SetDefaultBranchRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" + body: "*" + }; + option (google.api.method_signature) = "catalog"; + } + + // Get which branch is currently default branch set by + // [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] + // method under a specified parent catalog. + rpc GetDefaultBranch(GetDefaultBranchRequest) + returns (GetDefaultBranchResponse) { + option (google.api.http) = { + get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + }; + option (google.api.method_signature) = "catalog"; + } + + // Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]. + rpc GetCompletionConfig(GetCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s. + rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + patch: "/v2beta/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" + body: "completion_config" + }; + option (google.api.method_signature) = "completion_config,update_mask"; + } + + // Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + rpc GetAttributesConfig(GetAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + // + // The catalog attributes in the request will be updated in the catalog, or + // inserted if they do not exist. Existing catalog attributes not included in + // the request will remain unchanged. Attributes that are assigned to + // products, but do not exist at the catalog level, are always included in the + // response. The product attribute is assigned default values for missing + // catalog attribute fields, e.g., searchable and dynamic facetable options. + rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + patch: "/v2beta/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" + body: "attributes_config" + }; + option (google.api.method_signature) = "attributes_config,update_mask"; + } + + // Adds the specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to + // add already exists, an ALREADY_EXISTS error is returned. + rpc AddCatalogAttribute(AddCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" + body: "*" + }; + } + + // Removes the specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to + // remove does not exist, a NOT_FOUND error is returned. + rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" + body: "*" + }; + } + + // Replaces the specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating + // the catalog attribute with the same + // [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. + // + // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to + // replace does not exist, a NOT_FOUND error is returned. + rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" + body: "*" + }; + } +} + +// Request for +// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] +// method. +message ListCatalogsRequest { + // Required. The account resource name with an associated location. + // + // If the caller does not have permission to list + // [Catalog][google.cloud.retail.v2beta.Catalog]s under this location, + // regardless of whether or not this location exists, a PERMISSION_DENIED + // error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of [Catalog][google.cloud.retail.v2beta.Catalog]s to return. + // If unspecified, defaults to 50. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 2; + + // A page token + // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token], + // received from a previous + // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; +} + +// Response for +// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] +// method. +message ListCatalogsResponse { + // All the customer's [Catalog][google.cloud.retail.v2beta.Catalog]s. + repeated Catalog catalogs = 1; + + // A token that can be sent as + // [ListCatalogsRequest.page_token][google.cloud.retail.v2beta.ListCatalogsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request for +// [CatalogService.UpdateCatalog][google.cloud.retail.v2beta.CatalogService.UpdateCatalog] +// method. +message UpdateCatalogRequest { + // Required. The [Catalog][google.cloud.retail.v2beta.Catalog] to update. + // + // If the caller does not have permission to update the + // [Catalog][google.cloud.retail.v2beta.Catalog], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the [Catalog][google.cloud.retail.v2beta.Catalog] to update does not + // exist, a NOT_FOUND error is returned. + Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Catalog][google.cloud.retail.v2beta.Catalog] to update. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message to set a specified branch as new default_branch. +message SetDefaultBranchRequest { + // Full resource name of the catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // The final component of the resource name of a branch. + // + // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // If there are no sufficient active products in the targeted branch and + // [force][google.cloud.retail.v2beta.SetDefaultBranchRequest.force] is not + // set, a FAILED_PRECONDITION error is returned. + string branch_id = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Some note on this request, this can be retrieved by + // [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch] + // before next valid default branch set occurs. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string note = 3; + + // If set to true, it permits switching to a branch with + // [branch_id][google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id] + // even if it has no sufficient active products. + bool force = 4; +} + +// Request message to show which branch is currently the default branch. +message GetDefaultBranchRequest { + // The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response message of +// [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch]. +message GetDefaultBranchResponse { + // Full resource name of the branch id currently set as default branch. + string branch = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // The time when this branch is set to default. + google.protobuf.Timestamp set_time = 2; + + // This corresponds to + // [SetDefaultBranchRequest.note][google.cloud.retail.v2beta.SetDefaultBranchRequest.note] + // field, when this branch was set as default. + string note = 3; +} + +// Request for +// [CatalogService.GetCompletionConfig][google.cloud.retail.v2beta.CatalogService.GetCompletionConfig] +// method. +message GetCompletionConfigRequest { + // Required. Full CompletionConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/CompletionConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig] +// method. +message UpdateCompletionConfigRequest { + // Required. The + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. + // + // If the caller does not have permission to update the + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig], then a + // PERMISSION_DENIED error is returned. + // + // If the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to + // update does not exist, a NOT_FOUND error is returned. + CompletionConfig completion_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. + // The following are the only supported fields: + // + // * [CompletionConfig.matching_order][google.cloud.retail.v2beta.CompletionConfig.matching_order] + // * [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions] + // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2beta.CompletionConfig.min_prefix_length] + // * [CompletionConfig.auto_learning][google.cloud.retail.v2beta.CompletionConfig.auto_learning] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.GetAttributesConfig][google.cloud.retail.v2beta.CatalogService.GetAttributesConfig] +// method. +message GetAttributesConfigRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig] +// method. +message UpdateAttributesConfigRequest { + // Required. The + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. + AttributesConfig attributes_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. + // The following is the only supported field: + // + // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2beta.AttributesConfig.catalog_attributes] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute] +// method. +message AddCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute] +// method. +message RemoveCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The attribute name key of the + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove. + string key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute] +// method. +message ReplaceCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The updated + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to update. + // The following are NOT supported: + // + // * [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 3; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto new file mode 100644 index 00000000..ada7dd15 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto @@ -0,0 +1,760 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// At which level we offer configuration for attributes. +enum AttributeConfigLevel { + // Value used when unset. Defaults to + // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2beta.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; + + // At this level, we honor the attribute configurations set in + // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; + + // At this level, we honor the attribute configurations set in + // [CatalogConfig.attribute_configs][]. + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; +} + +// The type of solution. +enum SolutionType { + // Default value. + SOLUTION_TYPE_UNSPECIFIED = 0; + + // Used for Recommendations AI. + SOLUTION_TYPE_RECOMMENDATION = 1; + + // Used for Retail Search. + SOLUTION_TYPE_SEARCH = 2; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. Defaults to + // [SEARCH][]. + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; + + // Search use case. Expects the traffic has a non-empty + // [query][google.cloud.retail.v2beta.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_SEARCH = 1; + + // Browse use case. Expects the traffic has an empty + // [query][google.cloud.retail.v2beta.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_BROWSE = 2; +} + +// Metadata that is used to define a condition that triggers an action. +// A valid condition must specify at least one of 'query_terms' or +// 'products_filter'. If multiple fields are specified, the condition is met if +// all the fields are satisfied e.g. if a set of query terms and product_filter +// are set, then only items matching the product_filter for requests with a +// query matching the query terms wil get boosted. +message Condition { + // Query terms that we want to match on. + message QueryTerm { + // The value of the term to match on. + // Value cannot be empty. + // Value can have at most 3 terms if specified as a partial match. Each + // space separated string is considered as one term. + // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not + // allowed for partial match. + string value = 1; + + // Whether this is supposed to be a full or partial match. + bool full_match = 2; + } + + // Used for time-dependent conditions. + // Example: Want to have rule applied for week long sale. + message TimeRange { + // Start of time range. Range is inclusive. + google.protobuf.Timestamp start_time = 1; + + // End of time range. Range is inclusive. + google.protobuf.Timestamp end_time = 2; + } + + // A list (up to 10 entries) of terms to match the query on. If not + // specified, match all queries. + // If many query terms are specified, the condition + // is matched if any of the terms is a match (i.e. using the OR operator). + repeated QueryTerm query_terms = 1; + + // Range of time(s) specifying when Condition is active. + // Condition true if any time range matches. + repeated TimeRange active_time_range = 3; +} + +// A rule is a condition-action pair +// * A condition defines when a rule is to be triggered. +// * An action specifies what occurs on that trigger. +// Currently only boost rules are supported. +// Currently only supported by the search endpoint. +message Rule { + // A boost action to apply to results matching condition specified above. + message BoostAction { + // Strength of the condition boost, which must be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 1; + + // The filter can have a max size of 5000 characters. + // An expression which specifies which products to apply an action to. + // The syntax and supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string products_filter = 2; + } + + // * Rule Condition: + // - No [Condition][query_terms] provided is a global match. + // - 1 or more [Condition][query_terms] provided is combined with OR + // operator. + // * Action Input: The request query and filter that will be applied to the + // retrieved products, in addition to any filters already provided with the + // SearchRequest. The AND operator is used to combine the query's existing + // filters with the filter rule(s). NOTE: May result in 0 results when + // filters conflict. + // * Action Result: Filters the returned objects to be ONLY those that passed + // the filter. + message FilterAction { + // A filter to apply on the matching condition results. Supported features: + // + // * [filter][google.cloud.retail.v2beta.Rule.FilterAction.filter] must be + // set. + // * Filter syntax is identical to + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter]. + // See more + // details at the Retail Search + // [user guide](/retail/search/docs/filter-and-order#filter). + // * To filter products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string filter = 1; + } + + // Redirects a shopper to a specific page. + // * Rule Condition: + // - Must specify [Condition][query_terms]. + // * Action Input: Request Query + // * Action Result: Redirects shopper to provided uri. + message RedirectAction { + // URL must have length equal or less than 2000 characters. + string redirect_uri = 1; + } + + // Creates a set of terms that will be treated as synonyms of each other. + // Example: synonyms of "sneakers" and "shoes". + // * "sneakers" will use a synonym of "shoes". + // * "shoes" will use a synonym of "sneakers". + message TwowaySynonymsAction { + // Defines a set of synonyms. + // Can specify up to 100 synonyms. + // Must specify at least 2 synonyms. + repeated string synonyms = 1; + } + + // Maps a set of terms to a set of synonyms. + // Set of synonyms will be treated as synonyms of each query term only. + // `query_terms` will not be treated as synonyms of each other. + // Example: "sneakers" will use a synonym of "shoes". + // "shoes" will not use a synonym of "sneakers". + message OnewaySynonymsAction { + // Terms from the search query. + // Will treat synonyms as their synonyms. + // Not themselves synonyms of the synonyms. + // Can specify up to 100 terms. + repeated string query_terms = 3; + + // Defines a set of synonyms. + // Cannot contain duplicates. + // Can specify up to 100 synonyms. + repeated string synonyms = 4; + + // Will be [deprecated = true] post migration; + repeated string oneway_terms = 2; + } + + // Prevents `query_term` from being associated with specified terms during + // search. + // Example: Don't associate "gShoe" and "cheap". + message DoNotAssociateAction { + // Terms from the search query. + // Will not consider do_not_associate_terms for search if in search query. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Cannot contain duplicates or the query term. + // Can specify up to 100 terms. + repeated string do_not_associate_terms = 3; + + // Will be [deprecated = true] post migration; + repeated string terms = 1; + } + + // Replaces a term in the query. Multiple replacement candidates can be + // specified. All `query_terms` will be replaced with the replacement term. + // Example: Replace "gShoe" with "google shoe". + message ReplacementAction { + // Terms from the search query. + // Will be replaced by replacement term. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Term that will be used for replacement. + string replacement_term = 3; + + // Will be [deprecated = true] post migration; + string term = 1; + } + + // Prevents a term in the query from being used in search. + // Example: Don't search for "shoddy". + message IgnoreAction { + // Terms to ignore in the search query. + repeated string ignore_terms = 1; + } + + // An action must be provided. + oneof action { + // A boost action. + BoostAction boost_action = 2; + + // Redirects a shopper to a specific page. + RedirectAction redirect_action = 3; + + // Treats specific term as a synonym with a group of terms. + // Group of terms will not be treated as synonyms with the specific term. + OnewaySynonymsAction oneway_synonyms_action = 6; + + // Prevents term from being associated with other terms. + DoNotAssociateAction do_not_associate_action = 7; + + // Replaces specific terms in the query. + ReplacementAction replacement_action = 8; + + // Ignores specific terms from query during search. + IgnoreAction ignore_action = 9; + + // Filters results. + FilterAction filter_action = 10; + + // Treats a set of terms as synonyms of one another. + TwowaySynonymsAction twoway_synonyms_action = 11; + } + + // Required. The condition that triggers the rule. + // If the condition is empty, the rule will always apply. + Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// An intended audience of the [Product][google.cloud.retail.v2beta.Product] for +// whom it's sold. +message Audience { + // The genders of the audience. Strongly encouraged to use the standard + // values: "male", "female", "unisex". + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [gender](https://support.google.com/merchants/answer/6324479). Schema.org + // property + // [Product.audience.suggestedGender](https://schema.org/suggestedGender). + repeated string genders = 1; + + // The age groups of the audience. Strongly encouraged to use the standard + // values: "newborn" (up to 3 months old), "infant" (3–12 months old), + // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically + // teens or older). + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [age_group](https://support.google.com/merchants/answer/6324463). + // Schema.org property + // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and + // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). + repeated string age_groups = 2; +} + +// The color information of a [Product][google.cloud.retail.v2beta.Product]. +message ColorInfo { + // The standard color families. Strongly recommended to use the following + // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", + // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and + // "Mixed". Normally it is expected to have only 1 color family. May consider + // using single "Mixed" instead of multiple values. + // + // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string color_families = 1; + + // The color display names, which may be different from standard color family + // names, such as the color aliases used in the website frontend. Normally + // it is expected to have only 1 color. May consider using single "Mixed" + // instead of multiple values. + // + // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string colors = 2; +} + +// A custom attribute that is not explicitly modeled in +// [Product][google.cloud.retail.v2beta.Product]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated double numbers = 2; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2beta.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2beta.UserEvent]. + // + // Only set if type [text][google.cloud.retail.v2beta.CustomAttribute.text] is + // set. Otherwise, a INVALID_ARGUMENT error is returned. + optional bool searchable = 3; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2beta.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // indexed, so that it can be filtered, faceted or boosted in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2beta.UserEvent]. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter], + // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2beta.SearchRequest.boost_spec] + // for more details. + optional bool indexable = 4; +} + +// Fulfillment information, such as the store IDs for in-store pickup or region +// IDs for different shipping methods. +message FulfillmentInfo { + // The fulfillment type, including commonly used types (such as pickup in + // store and same day delivery), and custom types. Customers have to map + // custom types to their display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + string type = 1; + + // The IDs for this [type][google.cloud.retail.v2beta.FulfillmentInfo.type], + // such as the store IDs for + // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2beta.FulfillmentInfo.type] + // or the region IDs for + // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2beta.FulfillmentInfo.type]. + // + // A maximum of 3000 values are allowed. Each value must be a string with a + // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such + // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string place_ids = 2; +} + +// [Product][google.cloud.retail.v2beta.Product] image. Recommendations AI and +// Retail Search do not use product images to improve prediction and search +// results. However, product images can be returned in results, and are shown in +// prediction or search previews in the console. +message Image { + // Required. URI of the image. + // + // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Height of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 height = 2; + + // Width of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 width = 3; +} + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are set, then + // the lower bound is negative infinity. + // + // This field must be not larger than + // [max][google.cloud.retail.v2beta.Interval.max]. Otherwise, an + // INVALID_ARGUMENT error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are set, then + // the upper bound is positive infinity. + // + // This field must be not smaller than + // [min][google.cloud.retail.v2beta.Interval.min]. Otherwise, an + // INVALID_ARGUMENT error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// The price information of a [Product][google.cloud.retail.v2beta.Product]. +message PriceInfo { + // The price range of all + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. + message PriceRange { + // The inclusive + // [Product.pricing_info.price][google.cloud.retail.v2beta.PriceInfo.price] + // interval of all + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. + Interval price = 1; + + // The inclusive + // [Product.pricing_info.original_price][google.cloud.retail.v2beta.PriceInfo.original_price] + // internal of all + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. + Interval original_price = 2; + } + + // The 3-letter currency code defined in [ISO + // 4217](https://www.iso.org/iso-4217-currency-codes.html). + // + // If this field is an unrecognizable currency code, an INVALID_ARGUMENT + // error is returned. + // + // The [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s with the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] + // must share the same + // [currency_code][google.cloud.retail.v2beta.PriceInfo.currency_code]. + // Otherwise, a FAILED_PRECONDITION error is returned. + string currency_code = 1; + + // Price of the product. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). Schema.org + // property [Offer.price](https://schema.org/price). + float price = 2; + + // Price of the product without any discount. If zero, by default set to be + // the [price][google.cloud.retail.v2beta.PriceInfo.price]. + float original_price = 3; + + // The costs associated with the sale of a particular product. Used for gross + // profit reporting. + // + // * Profit = [price][google.cloud.retail.v2beta.PriceInfo.price] - + // [cost][google.cloud.retail.v2beta.PriceInfo.cost] + // + // Google Merchant Center property + // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). + float cost = 4; + + // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] + // starts to be effective. This can be set as a future timestamp, and the + // [price][google.cloud.retail.v2beta.PriceInfo.price] is only used for search + // after + // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. + // If so, the + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is + // used before + // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. + // + // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_effective_time = 5; + + // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] + // stops to be effective. The + // [price][google.cloud.retail.v2beta.PriceInfo.price] is used for search + // before + // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. + // If this field is set, the + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is + // used after + // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. + // + // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_expire_time = 6; + + // Output only. The price range of all the child + // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s grouped together on the + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]. Only populated for + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. + // Do not set this field in API requests. + PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The rating of a [Product][google.cloud.retail.v2beta.Product]. +message Rating { + // The total number of ratings. This value is independent of the value of + // [rating_histogram][google.cloud.retail.v2beta.Rating.rating_histogram]. + // + // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 rating_count = 1; + + // The average rating of the [Product][google.cloud.retail.v2beta.Product]. + // + // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is + // returned. + float average_rating = 2; + + // List of rating counts per rating value (index = rating - 1). The list is + // empty if there is no rating. If the list is non-empty, its size is + // always 5. Otherwise, an INVALID_ARGUMENT error is returned. + // + // For example, [41, 14, 13, 47, 303]. It means that the + // [Product][google.cloud.retail.v2beta.Product] got 41 ratings with 1 star, + // 14 ratings with 2 star, and so on. + repeated int32 rating_histogram = 3; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. + // + // Always use a hashed value for this ID. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string user_id = 1; + + // The end user's IP address. This field is used to extract location + // information for personalization. + // + // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 + // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This should not be set when: + // + // * setting + // [SearchRequest.user_info][google.cloud.retail.v2beta.SearchRequest.user_info]. + // * using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] + // is set. + string ip_address = 2; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][google.cloud.retail.v2beta.SearchResponse.sponsored_results]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] + // is set. + string user_agent = 3; + + // True if the request is made directly from the end user, in which case the + // [ip_address][google.cloud.retail.v2beta.UserInfo.ip_address] and + // [user_agent][google.cloud.retail.v2beta.UserInfo.user_agent] can be + // populated from the HTTP request. This flag should be set only if the API + // request is made directly from the end user such as a mobile app (and not if + // a gateway or a server is processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent]. + bool direct_user_request = 4; +} + +// The inventory information at a place (e.g. a store) identified +// by a place ID. +message LocalInventory { + // The place ID for the current set of inventory information. + string place_id = 1; + + // Product price and cost information. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 2; + + // Additional local inventory attributes, for example, store name, promotion + // tags, etc. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * At most 30 attributes are allowed. + // * The key must be a UTF-8 encoded string with a length limit of 32 + // characters. + // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, + // key0LikeThis or KEY_1_LIKE_THIS. + // * The attribute values must be of the same type (text or number). + // * Only 1 value is allowed for each attribute. + // * For text values, the length limit is 256 UTF-8 characters. + // * The attribute does not support search. The `searchable` field should be + // unset or set to false. + // * The max summed total bytes of custom attribute keys and values per + // product is 5MiB. + map attributes = 3; + + // Input only. Supported fulfillment types. Valid fulfillment type values + // include commonly used types (such as pickup in store and same day + // delivery), and custom types. Customers have to map custom types to their + // display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string fulfillment_types = 4 + [(google.api.field_behavior) = INPUT_ONLY]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto new file mode 100644 index 00000000..6a1f2907 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto @@ -0,0 +1,199 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Auto-completion service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service CompletionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified prefix with keyword suggestions. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }; + } + + // Bulk import of processed completion dataset. + // + // Request processing is asynchronous. Partial updating is not supported. + // + // The operation is successfully finished only after the imported suggestions + // are indexed successfully and ready for serving. The process takes hours. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc ImportCompletionData(ImportCompletionDataRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ImportCompletionDataResponse" + metadata_type: "google.cloud.retail.v2beta.ImportMetadata" + }; + } +} + +// Auto-complete parameters. +message CompleteQueryRequest { + // Required. Catalog for which the completion is performed. + // + // Full resource name of catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The query used to generate suggestions. + // + // The maximum number of allowed characters is 255. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required field. A unique identifier for tracking visitors. For example, + // this could be implemented with an HTTP cookie, which should be able to + // uniquely identify a visitor on a single device. This unique identifier + // should not change if the visitor logs in or out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 7; + + // The language filters applied to the output suggestions. If set, it should + // contain the language of the query. If not set, suggestions are returned + // without considering language restrictions. This is the BCP-47 language + // code, such as "en-US" or "sr-Latn". For more information, see [Tags for + // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + // number of language codes is 3. + repeated string language_codes = 3; + + // The device type context for completion suggestions. + // It is useful to apply different suggestions on different device types, e.g. + // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + // types. + // + // Supported formats: + // + // * `UNKNOWN_DEVICE_TYPE` + // + // * `DESKTOP` + // + // * `MOBILE` + // + // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + string device_type = 4; + + // Determines which dataset to use for fetching completion. "user-data" will + // use the imported dataset through + // [CompletionService.ImportCompletionData][google.cloud.retail.v2beta.CompletionService.ImportCompletionData]. + // "cloud-retail" will use the dataset generated by cloud retail based on user + // events. If leave empty, it will use the "user-data". + // + // Current supported values: + // + // * user-data + // + // * cloud-retail + // This option requires additional allowlisting. Before using cloud-retail, + // contact Cloud Retail support team first. + string dataset = 6; + + // Completion max suggestions. If left unset or set to 0, then will fallback + // to the configured value + // [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions]. + // + // The maximum allowed max suggestions is 20. If it is set higher, it will be + // capped by 20. + int32 max_suggestions = 5; +} + +// Response of the auto-complete query. +message CompleteQueryResponse { + // Resource that represents completion results. + message CompletionResult { + // The suggestion for the query. + string suggestion = 1; + + // Custom attributes for the suggestion term. + // * For "user-data", the attributes are additional custom attributes + // ingested through BigQuery. + // * For "cloud-retail", the attributes are product attributes generated + // by Cloud Retail. + map attributes = 2; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Results of the matching suggestions. The result list is ordered and the + // first result is top suggestion. + repeated CompletionResult completion_results = 1; + + // A unique complete token. This should be included in the + // [UserEvent.completion_detail][google.cloud.retail.v2beta.UserEvent.completion_detail] + // for search events resulting from this completion, which enables accurate + // attribution of complete model performance. + string attribution_token = 2; + + // Matched recent searches of this user. The maximum number of recent searches + // is 10. This field is a restricted feature. Contact Retail Search support + // team if you are interested in enabling it. + // + // This feature is only available when + // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2beta.CompleteQueryRequest.visitor_id] + // field is set and [UserEvent][google.cloud.retail.v2beta.UserEvent] is + // imported. The recent searches satisfy the follow rules: + // * They are ordered from latest to oldest. + // * They are matched with + // [CompleteQueryRequest.query][google.cloud.retail.v2beta.CompleteQueryRequest.query] + // case insensitively. + // * They are transformed to lower cases. + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto new file mode 100644 index 00000000..e5562227 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto @@ -0,0 +1,84 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configures dynamic serving time metadata that is used to pre and post +// process search/recommendation model results. +message Control { + option (google.api.resource) = { + type: "retail.googleapis.com/Control" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }; + + // The behavior/type of the control + // + // A behavior/type must be specified on creation. Type cannot be changed once + // specified (e.g. A Rule control will always be a Rule control.). An + // INVALID_ARGUMENT will be returned if either condition is violated. + oneof control { + // A facet specification to perform faceted search. + SearchRequest.FacetSpec facet_spec = 3; + + // A rule control - a condition-action pair. + // Enacts a set action when the condition is triggered. + // For example: Boost "gShoe" when query full matches "Running Shoes". + Rule rule = 4; + } + + // Immutable. Fully qualified name + // projects/*/locations/global/catalogs/*/controls/* + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable control display name. Used in Retail UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is thrown. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Output only. List of serving configuration ids that that are associated + // with this control. Note the association is managed via the ServingConfig, + // this is an output only denormalizeed view. Assumed to be in the same + // catalog. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the serving config is used + // for. Currently we support setting only one type of solution at creation + // time. + // + // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. + // If no solution type is provided at creation time, will default to + // SOLUTION_TYPE_SEARCH. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto new file mode 100644 index 00000000..922c46f2 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto @@ -0,0 +1,184 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/control.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for modifying Control. +service ControlService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a Control. + // + // If the [Control][google.cloud.retail.v2beta.Control] to create already + // exists, an ALREADY_EXISTS error is returned. + rpc CreateControl(CreateControlRequest) returns (Control) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" + body: "control" + }; + option (google.api.method_signature) = "parent,control,control_id"; + } + + // Deletes a Control. + // + // If the [Control][google.cloud.retail.v2beta.Control] to delete does not + // exist, a NOT_FOUND error is returned. + rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Control. + // + // [Control][google.cloud.retail.v2beta.Control] cannot be set to a different + // oneof field, if so an INVALID_ARGUMENT is returned. If the + // [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a + // NOT_FOUND error is returned. + rpc UpdateControl(UpdateControlRequest) returns (Control) { + option (google.api.http) = { + patch: "/v2beta/{control.name=projects/*/locations/*/catalogs/*/controls/*}" + body: "control" + }; + option (google.api.method_signature) = "control,update_mask"; + } + + // Gets a Control. + rpc GetControl(GetControlRequest) returns (Control) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all Controls linked to this catalog. + rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request for CreateControl method. +message CreateControlRequest { + // Required. Full resource name of parent catalog. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The Control to create. + Control control = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the Control, which will become the final + // component of the Control's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string control_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateControl method. +message UpdateControlRequest { + // Required. The Control to update. + Control control = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Control][google.cloud.retail.v2beta.Control] to update. The following are + // NOT supported: + // + // * [Control.name][google.cloud.retail.v2beta.Control.name] + // + // If not set or empty, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteControl method. +message DeleteControlRequest { + // Required. The resource name of the Control to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for GetControl method. +message GetControlRequest { + // Required. The resource name of the Control to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for ListControls method. +message ListControlsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 50. Max allowed value is 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListControls` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2beta.ListControlsRequest.filter] is unset. + // * List controls that are used in a single ServingConfig: + // 'serving_config = "boosted_home_page_cvr"' + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListControls method. +message ListControlsResponse { + // All the Controls for a given catalog. + repeated Control controls = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto new file mode 100644 index 00000000..249f5011 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto @@ -0,0 +1,77 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ExportConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configuration of destination for Export related errors. +message ExportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage path for import errors. This must be an empty, + // existing Cloud Storage bucket. Export errors will be written to a file in + // this bucket, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Metadata related to the progress of the Export operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ExportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Response of the ExportProductsRequest. If the long running +// operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ExportErrorsConfig errors_config = 2; +} + +// Response of the ExportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ExportErrorsConfig errors_config = 2; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto new file mode 100644 index 00000000..c1390ab0 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto @@ -0,0 +1,397 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/cloud/retail/v2beta/user_event.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Google Cloud Storage location for input content. +// format. +message GcsSource { + // Required. Google Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. A request can + // contain at most 100 files, and each file can be up to 2 GB. See + // [Importing product + // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) + // for the expected file format and setup instructions. + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2beta.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. + // * `user_event_ga360`: Using + // https://support.google.com/analytics/answer/3437719. + // + // Supported values for control imports: + // + // * 'control' (default): One JSON + // [Control][google.cloud.retail.v2beta.Control] per line. + // + // Supported values for catalog attribute imports: + // + // * 'catalog_attribute' (default): One CSV + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + google.type.Date partition_date = 6; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 5; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 3; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2beta.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. + // * `user_event_ga360`: + // The schema is available here: + // https://support.google.com/analytics/answer/3437719. + // * `user_event_ga4`: This feature is in private preview. Please contact the + // support team for importing Google Analytics 4 events. + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for auto-completion imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + string data_schema = 4; +} + +// The inline source for the input config for ImportProducts method. +message ProductInlineSource { + // Required. A list of products to update/create. Each product must have a + // valid [Product.id][google.cloud.retail.v2beta.Product.id]. Recommended max + // of 100 items. + repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The inline source for the input config for ImportUserEvents method. +message UserEventInlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configuration of destination for Import related errors. +message ImportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors will be written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for Import methods. +message ImportProductsRequest { + // Indicates how imported products are reconciled with the existing products + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new products or updates existing products. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire product dataset. Existing + // products may be deleted if they are not present in the source location. + // + // Can only be set while using + // [BigQuerySource][google.cloud.retail.v2beta.BigQuerySource]. And the + // BigQuery dataset must be created in the data location "us (multiple + // regions in United States)", otherwise a PERMISSION_DENIED error is + // thrown. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + FULL = 2; + } + + // Required. + // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + // + // If no updateMask is specified, requires products.create permission. + // If updateMask is specified, requires products.update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Deprecated. This field has no effect. + string request_id = 6 [deprecated = true]; + + // Required. The desired input location of the data. + ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. + ImportErrorsConfig errors_config = 3; + + // Indicates which fields in the provided imported 'products' to update. If + // not set, will by default update all fields. + google.protobuf.FieldMask update_mask = 4; + + // The mode of reconciliation between existing products and the products to be + // imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 5; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + string notification_pubsub_topic = 7; +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // Required. `projects/1234/locations/global/catalogs/default_catalog` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + UserEventInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorsConfig errors_config = 3; +} + +// Request message for ImportCompletionData methods. +message ImportCompletionDataRequest { + // Required. The catalog which the suggestions dataset belongs to. + // + // Format: `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + CompletionDataInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 3; +} + +// The input config source for products. +message ProductInputConfig { + // Required. The source of the input. + oneof source { + // The Inline source for the input content for products. + ProductInlineSource product_inline_source = 1; + + // Google Cloud Storage location for the input content. + GcsSource gcs_source = 2; + + // BigQuery input source. + BigQuerySource big_query_source = 3; + } +} + +// The input config source for user events. +message UserEventInputConfig { + // The source of the input. + oneof source { + // Required. The Inline source for the input content for UserEvents. + UserEventInlineSource user_event_inline_source = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Google Cloud Storage location for the input content. + GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource big_query_source = 3 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// The input config source for completion data. +message CompletionDataInputConfig { + // The source of the input. + // + // Supported + // [BigQuerySource.data_schema][google.cloud.retail.v2beta.BigQuerySource.data_schema] + // values for suggestions imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + oneof source { + // Required. BigQuery input source. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + BigQuerySource big_query_source = 1 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// Metadata related to the progress of the Import operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ImportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; + + // Deprecated. This field is never set. + string request_id = 5 [deprecated = true]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; +} + +// Response of the +// [ImportProductsRequest][google.cloud.retail.v2beta.ImportProductsRequest]. If +// the long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorsConfig errors_config = 2; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorsConfig errors_config = 2; + + // Aggregated statistics of user event import status. + UserEventImportSummary import_summary = 3; +} + +// A summary of import result. The UserEventImportSummary summarizes +// the import status for user events. +message UserEventImportSummary { + // Count of user events imported with complete existing catalog information. + int64 joined_events_count = 1; + + // Count of user events imported, but with catalog information not found + // in the imported catalog. + int64 unjoined_events_count = 2; +} + +// Response of the +// [ImportCompletionDataRequest][google.cloud.retail.v2beta.ImportCompletionDataRequest]. +// If the long running operation is done, this message is returned by the +// google.longrunning.Operations.response field if the operation is successful. +message ImportCompletionDataResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto new file mode 100644 index 00000000..c5ec1871 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto @@ -0,0 +1,194 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2beta/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "PredictionServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for making recommendation prediction. +service PredictionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation prediction. + rpc Predict(PredictRequest) returns (PredictResponse) { + option (google.api.http) = { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" + body: "*" + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} + // The ID of the Recommendations AI placement. Before you can request + // predictions from your model, you must create at least one placement for it. + // For more information, see [Managing + // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + // + // The full list of available placements can be seen at + // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the predict request. Note that this user event detail + // won't be ingested to userEvent logs. Thus, a separate userEvent write + // request is required for event logging. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return per page. Set this property + // to the number of prediction results needed. If zero, the service will + // choose a reasonable default. The maximum allowed value is 100. Values + // above 100 will be coerced to 100. + int32 page_size = 3; + + // The previous PredictResponse.next_page_token. + string page_token = 4; + + // Filter for restricting prediction results with a length limit of 5,000 + // characters. Accepts values for tags and the `filterOutOfStockItems` flag. + // + // * Tag expressions. Restricts predictions to products that match all of the + // specified tags. Boolean operators `OR` and `NOT` are supported if the + // expression is enclosed in parentheses, and must be separated from the + // tag values by a space. `-"tagA"` is also supported and is equivalent to + // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + // with a size limit of 1,000 characters. + // + // Note: "Recently viewed" models don't support tag filtering at the + // moment. + // + // * filterOutOfStockItems. Restricts predictions to products that do not + // have a + // stockState value of OUT_OF_STOCK. + // + // Examples: + // + // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + // * filterOutOfStockItems tag=(-"promotional") + // * filterOutOfStockItems + // + // If your filter blocks all prediction results, the API will return generic + // (unfiltered) popular products. If you only want results strictly matching + // the filters, set `strictFiltering` to True in `PredictRequest.params` to + // receive empty results instead. + // Note that the API will never return items with storageStatus of "EXPIRED" + // or "DELETED" regardless of filter choices. + string filter = 5; + + // Use validate only mode for this prediction query. If set to true, a + // dummy model will be used that returns arbitrary products. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 6; + + // Additional domain specific parameters for the predictions. + // + // Allowed values: + // + // * `returnProduct`: Boolean. If set to true, the associated product + // object will be returned in the `results.metadata` field in the + // prediction response. + // * `returnScore`: Boolean. If set to true, the prediction 'score' + // corresponding to each returned product will be set in the + // `results.metadata` field in the prediction response. The given + // 'score' indicates the probability of an product being clicked/purchased + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular products instead of empty if + // your filter blocks all prediction results. + // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-price-reranking', 'low-price-reranking', + // 'medium-price-reranking', 'high-price-reranking'}. This gives + // request-level control and adjusts prediction results based on product + // price. + // * `diversityLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-diversity', 'low-diversity', + // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + // request-level control and adjusts prediction results based on product + // category. + map params = 7; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters, and cannot be empty. Values can be empty, and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 8; +} + +// Response message for predict method. +message PredictResponse { + // PredictionResult represents the recommendation prediction results. + message PredictionResult { + // ID of the recommended product + string id = 1; + + // Additional product metadata / annotations. + // + // Possible values: + // + // * `product`: JSON representation of the product. Will be set if + // `returnProduct` is set to true in `PredictRequest.params`. + // * `score`: Prediction score in double value. Will be set if + // `returnScore` is set to true in `PredictRequest.params`. + map metadata = 2; + } + + // A list of recommended products. The order represents the ranking (from the + // most relevant product to the least). + repeated PredictionResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this + // recommendation, which enables accurate attribution of recommendation model + // performance. + string attribution_token = 2; + + // IDs of products in the request that were missing from the inventory. + repeated string missing_ids = 3; + + // True if the validateOnly property was set in the request. + bool validate_only = 4; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto new file mode 100644 index 00000000..4e6dfec8 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto @@ -0,0 +1,566 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/promotion.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" +}; + +// Product captures all metadata information of items to be recommended or +// searched. +message Product { + option (google.api.resource) = { + type: "retail.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }; + + // The type of this product. + enum Type { + // Default value. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] + // if unset. + TYPE_UNSPECIFIED = 0; + + // The primary type. + // + // As the primary unit for predicting, indexing and search serving, a + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] is grouped with multiple + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s. + PRIMARY = 1; + + // The variant type. + // + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s usually share some common + // attributes on the same + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s, but they have variant + // attributes like different colors, sizes and prices, etc. + VARIANT = 2; + + // The collection type. Collection products are bundled + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s or + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s that are sold together, + // such as a jewelry set with necklaces, earrings and rings, etc. + COLLECTION = 3; + } + + // Product availability. If this field is unspecified, the product is + // assumed to be in stock. + enum Availability { + // Default product availability. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK] + // if unset. + AVAILABILITY_UNSPECIFIED = 0; + + // Product in stock. + IN_STOCK = 1; + + // Product out of stock. + OUT_OF_STOCK = 2; + + // Product that is in pre-order state. + PREORDER = 3; + + // Product that is back-ordered (i.e. temporarily out of stock). + BACKORDER = 4; + } + + oneof expiration { + // The timestamp when this product becomes unavailable for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // If it is set, the [Product][google.cloud.retail.v2beta.Product] is not + // available for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // after [expire_time][google.cloud.retail.v2beta.Product.expire_time]. + // However, the product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // [expire_time][google.cloud.retail.v2beta.Product.expire_time] must be + // later than + // [available_time][google.cloud.retail.v2beta.Product.available_time] and + // [publish_time][google.cloud.retail.v2beta.Product.publish_time], + // otherwise an INVALID_ARGUMENT error is thrown. + // + // Corresponding properties: Google Merchant Center property + // [expiration_date](https://support.google.com/merchants/answer/6324499). + google.protobuf.Timestamp expire_time = 16; + + // Input only. The TTL (time to live) of the product. + // + // If it is set, it must be a non-negative value, and + // [expire_time][google.cloud.retail.v2beta.Product.expire_time] is set as + // current timestamp plus [ttl][google.cloud.retail.v2beta.Product.ttl]. The + // derived [expire_time][google.cloud.retail.v2beta.Product.expire_time] is + // returned in the output and [ttl][google.cloud.retail.v2beta.Product.ttl] + // is left blank when retrieving the + // [Product][google.cloud.retail.v2beta.Product]. + // + // If it is set, the product is not available for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // after current timestamp plus + // [ttl][google.cloud.retail.v2beta.Product.ttl]. However, the product can + // still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + google.protobuf.Duration ttl = 17 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Immutable. Full resource name of the product, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. [Product][google.cloud.retail.v2beta.Product] identifier, which + // is the final component of [name][google.cloud.retail.v2beta.Product.name]. + // For example, this field is "id_1", if + // [name][google.cloud.retail.v2beta.Product.name] is + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [id](https://support.google.com/merchants/answer/6324405). Schema.org + // property [Product.sku](https://schema.org/sku). + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The type of the product. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] + // if unset. + Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Variant group identifier. Must be an + // [id][google.cloud.retail.v2beta.Product.id], with the same parent branch + // with this product. Otherwise, an error is thrown. + // + // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s, this field can only be + // empty or set to the same value as + // [id][google.cloud.retail.v2beta.Product.id]. + // + // For VARIANT [Product][google.cloud.retail.v2beta.Product]s, this field + // cannot be empty. A maximum of 2,000 products are allowed to share the same + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [item_group_id](https://support.google.com/merchants/answer/6324507). + // Schema.org property + // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). + string primary_product_id = 4; + + // The [id][google.cloud.retail.v2beta.Product.id] of the collection members + // when [type][google.cloud.retail.v2beta.Product.type] is + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]. + // + // Non-existent product ids are allowed. + // The [type][google.cloud.retail.v2beta.Product.type] of the members must be + // either [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] or + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] otherwise + // and INVALID_ARGUMENT error is thrown. Should not set it for other types. A + // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is + // return. + repeated string collection_member_ids = 5; + + // The Global Trade Item Number (GTIN) of the product. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Corresponding properties: Google Merchant Center property + // [gtin](https://support.google.com/merchants/answer/6324461). + // Schema.org property + // [Product.isbn](https://schema.org/isbn), + // [Product.gtin8](https://schema.org/gtin8), + // [Product.gtin12](https://schema.org/gtin12), + // [Product.gtin13](https://schema.org/gtin13), or + // [Product.gtin14](https://schema.org/gtin14). + // + // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. + string gtin = 6; + + // Product categories. This field is repeated for supporting one product + // belonging to several parallel categories. Strongly recommended using the + // full path for better search / recommendation quality. + // + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // For example, if a shoes product belongs to both + // ["Shoes & Accessories" -> "Shoes"] and + // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be + // represented as: + // + // "categories": [ + // "Shoes & Accessories > Shoes", + // "Sports & Fitness > Athletic Clothing > Shoes" + // ] + // + // Must be set for + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] otherwise an INVALID_ARGUMENT + // error is returned. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [google_product_category][mc_google_product_category]. Schema.org property + // [Product.category] (https://schema.org/category). + // + // [mc_google_product_category]: + // https://support.google.com/merchants/answer/6324436 + repeated string categories = 7; + + // Required. Product title. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [title](https://support.google.com/merchants/answer/6324415). Schema.org + // property [Product.name](https://schema.org/name). + string title = 8 [(google.api.field_behavior) = REQUIRED]; + + // The brands of the product. + // + // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded + // string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [brand](https://support.google.com/merchants/answer/6324351). Schema.org + // property [Product.brand](https://schema.org/brand). + repeated string brands = 9; + + // Product description. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [description](https://support.google.com/merchants/answer/6324468). + // Schema.org property [Product.description](https://schema.org/description). + string description = 10; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // + // For product prediction, this field is ignored and the model automatically + // detects the text language. The + // [Product][google.cloud.retail.v2beta.Product] can include text in different + // languages, but duplicating [Product][google.cloud.retail.v2beta.Product]s + // to provide text in multiple languages can result in degraded model + // performance. + // + // For product search this field is in use. It defaults to "en-US" if unset. + string language_code = 11; + + // Highly encouraged. Extra product attributes to be included. For example, + // for products, this could include the store name, vendor, style, color, etc. + // These are very strong signals for recommendation model, thus we highly + // recommend providing the attributes here. + // + // Features that can take on one of a limited number of possible values. Two + // types of features can be set are: + // + // Textual features. some examples would be the brand/maker of a product, or + // country of a customer. Numerical features. Some examples would be the + // height/weight of a product, or age of a customer. + // + // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, + // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} + // }`. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * Max entries count: 200. + // * The key must be a UTF-8 encoded string with a length limit of 128 + // characters. + // * For indexable attribute, the key must match the pattern: + // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or + // `KEY_1_LIKE_THIS`. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a non-empty UTF-8 encoded string with a + // length limit of 256 characters. + // * For number attributes, at most 400 values are allowed. + map attributes = 12; + + // Custom tags associated with the product. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. This value must be a UTF-8 + // encoded string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This tag can be used for filtering recommendation results by passing the + // tag as part of the + // [PredictRequest.filter][google.cloud.retail.v2beta.PredictRequest.filter]. + // + // Corresponding properties: Google Merchant Center property + // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). + repeated string tags = 13; + + // Product price and cost information. + // + // Corresponding properties: Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 14; + + // The rating of this product. + Rating rating = 15; + + // The timestamp when this [Product][google.cloud.retail.v2beta.Product] + // becomes available for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + google.protobuf.Timestamp available_time = 18; + + // The online availability of the + // [Product][google.cloud.retail.v2beta.Product]. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK]. + // + // Corresponding properties: Google Merchant Center property + // [availability](https://support.google.com/merchants/answer/6324448). + // Schema.org property [Offer.availability](https://schema.org/availability). + Availability availability = 19; + + // The available quantity of the item. + google.protobuf.Int32Value available_quantity = 20; + + // Fulfillment information, such as the store IDs for in-store pickup or + // region IDs for different shipping methods. + // + // All the elements must have distinct + // [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated FulfillmentInfo fulfillment_info = 21; + + // Canonical URL directly linking to the product detail page. + // + // It is strongly recommended to provide a valid uri for the product, + // otherwise the service performance could be significantly degraded. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [link](https://support.google.com/merchants/answer/6324416). Schema.org + // property [Offer.url](https://schema.org/url). + string uri = 22; + + // Product images for the product. We highly recommend putting the main + // image first. + // + // A maximum of 300 images are allowed. + // + // Corresponding properties: Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + repeated Image images = 23; + + // The target group associated with a given audience (e.g. male, veterans, + // car owners, musicians, etc.) of the product. + Audience audience = 24; + + // The color of the product. + // + // Corresponding properties: Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + ColorInfo color_info = 25; + + // The size of the product. To represent different size systems or size types, + // consider using this format: [[[size_system:]size_type:]size_value]. + // + // For example, in "US:MENS:M", "US" represents size system; "MENS" represents + // size type; "M" represents size value. In "GIRLS:27", size system is empty; + // "GIRLS" represents size type; "27" represents size value. In "32 inches", + // both size system and size type are empty, while size value is "32 inches". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [size](https://support.google.com/merchants/answer/6324492), + // [size_type](https://support.google.com/merchants/answer/6324497), and + // [size_system](https://support.google.com/merchants/answer/6324502). + // Schema.org property [Product.size](https://schema.org/size). + repeated string sizes = 26; + + // The material of the product. For example, "leather", "wooden". + // + // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 200 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [material](https://support.google.com/merchants/answer/6324410). Schema.org + // property [Product.material](https://schema.org/material). + repeated string materials = 27; + + // The pattern or graphic print of the product. For example, "striped", "polka + // dot", "paisley". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org + // property [Product.pattern](https://schema.org/pattern). + repeated string patterns = 28; + + // The condition of the product. Strongly encouraged to use the standard + // values: "new", "refurbished", "used". + // + // A maximum of 1 value is allowed per + // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [condition](https://support.google.com/merchants/answer/6324469). + // Schema.org property + // [Offer.itemCondition](https://schema.org/itemCondition). + repeated string conditions = 29; + + // The promotions applied to the product. A maximum of 10 values are allowed + // per [Product][google.cloud.retail.v2beta.Product]. Only + // [Promotion.promotion_id][google.cloud.retail.v2beta.Promotion.promotion_id] + // will be used, other fields will be ignored if set. + repeated Promotion promotions = 34; + + // The timestamp when the product is published by the retailer for the first + // time, which indicates the freshness of the products. Note that this field + // is different from + // [available_time][google.cloud.retail.v2beta.Product.available_time], given + // it purely describes product freshness regardless of when it is available on + // search and recommendation. + google.protobuf.Timestamp publish_time = 33; + + // Indicates which fields in the + // [Product][google.cloud.retail.v2beta.Product]s are returned in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse]. + // + // Supported fields for all [type][google.cloud.retail.v2beta.Product.type]s: + // + // * [audience][google.cloud.retail.v2beta.Product.audience] + // * [availability][google.cloud.retail.v2beta.Product.availability] + // * [brands][google.cloud.retail.v2beta.Product.brands] + // * [color_info][google.cloud.retail.v2beta.Product.color_info] + // * [conditions][google.cloud.retail.v2beta.Product.conditions] + // * [gtin][google.cloud.retail.v2beta.Product.gtin] + // * [materials][google.cloud.retail.v2beta.Product.materials] + // * [name][google.cloud.retail.v2beta.Product.name] + // * [patterns][google.cloud.retail.v2beta.Product.patterns] + // * [price_info][google.cloud.retail.v2beta.Product.price_info] + // * [rating][google.cloud.retail.v2beta.Product.rating] + // * [sizes][google.cloud.retail.v2beta.Product.sizes] + // * [title][google.cloud.retail.v2beta.Product.title] + // * [uri][google.cloud.retail.v2beta.Product.uri] + // + // Supported fields only for + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]: + // + // * [categories][google.cloud.retail.v2beta.Product.categories] + // * [description][google.cloud.retail.v2beta.Product.description] + // * [images][google.cloud.retail.v2beta.Product.images] + // + // Supported fields only for + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]: + // + // * Only the first image in + // [images][google.cloud.retail.v2beta.Product.images] + // + // To mark [attributes][google.cloud.retail.v2beta.Product.attributes] as + // retrievable, include paths of the form "attributes.key" where "key" is the + // key of a custom attribute, as specified in + // [attributes][google.cloud.retail.v2beta.Product.attributes]. + // + // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], the + // following fields are always returned in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] by default: + // + // * [name][google.cloud.retail.v2beta.Product.name] + // + // For [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT], the + // following fields are always returned in by default: + // + // * [name][google.cloud.retail.v2beta.Product.name] + // * [color_info][google.cloud.retail.v2beta.Product.color_info] + // + // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] may increase + // response payload size and serving latency. + google.protobuf.FieldMask retrievable_fields = 30; + + // Output only. Product variants grouped together on primary product which + // share similar product attributes. It's automatically grouped by + // [primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] + // for all the product variants. Only populated for + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. + // Do not set this field in API requests. + repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto new file mode 100644 index 00000000..0ad73436 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto @@ -0,0 +1,829 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for ingesting [Product][google.cloud.retail.v2beta.Product] +// information of the customer's website. +service ProductService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Product][google.cloud.retail.v2beta.Product]. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Gets a [Product][google.cloud.retail.v2beta.Product]. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Product][google.cloud.retail.v2beta.Product]s. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a [Product][google.cloud.retail.v2beta.Product]. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v2beta/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Deletes a [Product][google.cloud.retail.v2beta.Product]. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. + // + // Request processing may be synchronous. No partial updating is supported. + // Non-existing items are created. + // + // Note that it is possible for a subset of the + // [Product][google.cloud.retail.v2beta.Product]s to be successfully updated. + rpc ImportProducts(ImportProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ImportProductsResponse" + metadata_type: "google.cloud.retail.v2beta.ImportMetadata" + }; + } + + // Updates inventory information for a + // [Product][google.cloud.retail.v2beta.Product] while respecting the last + // update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, updates are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // When inventory is updated with + // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], + // the specified inventory field value(s) will overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update time for the specified inventory fields will be overwritten to the + // time of the + // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or + // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // request. + // + // If no inventory fields are set in + // [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], + // then any pre-existing inventory information for this product will be used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], + // then any existing inventory information will be preserved. + // + // Pre-existing inventory information can only be updated with + // [SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], + // [AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], + // and + // [RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" + body: "*" + }; + option (google.api.method_signature) = "inventory,set_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.SetInventoryResponse" + metadata_type: "google.cloud.retail.v2beta.SetInventoryMetadata" + }; + } + + // Incrementally adds place IDs to + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the added place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata" + }; + } + + // Incrementally removes place IDs from a + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the removed place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata" + }; + } + + // Updates local inventory information for a + // [Product][google.cloud.retail.v2beta.Product] at a list of places, while + // respecting the last update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // inventory information. If the request is valid, the update will be enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddLocalInventories(AddLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.AddLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2beta.AddLocalInventoriesMetadata" + }; + } + + // Remove local inventory information for a + // [Product][google.cloud.retail.v2beta.Product] at a list of places at a + // removal timestamp. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, removals are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata" + }; + } +} + +// Request message for [CreateProduct][] method. +message CreateProductRequest { + // Required. The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The [Product][google.cloud.retail.v2beta.Product] to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Product][google.cloud.retail.v2beta.Product], which will become the final + // component of the [Product.name][google.cloud.retail.v2beta.Product.name]. + // + // If the caller does not have permission to create the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // This field must be unique among all + // [Product][google.cloud.retail.v2beta.Product]s with the same + // [parent][google.cloud.retail.v2beta.CreateProductRequest.parent]. + // Otherwise, an ALREADY_EXISTS error is returned. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string product_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [GetProduct][] method. +message GetProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the requested [Product][google.cloud.retail.v2beta.Product] does not + // exist, a NOT_FOUND error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for [UpdateProduct][] method. +message UpdateProductRequest { + // Required. The product to update/create. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2beta.Product] to update does not + // exist and + // [allow_missing][google.cloud.retail.v2beta.UpdateProductRequest.allow_missing] + // is not set, a NOT_FOUND error is returned. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Product][google.cloud.retail.v2beta.Product] to update. The immutable and + // output only fields are NOT supported. If not set, all supported fields (the + // fields that are neither immutable nor output only) are updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, a new [Product][google.cloud.retail.v2beta.Product] will be + // created. In this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for [DeleteProduct][] method. +message DeleteProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to delete the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2beta.Product] to delete does not + // exist, a NOT_FOUND error is returned. + // + // The [Product][google.cloud.retail.v2beta.Product] to delete can neither be + // a + // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2beta.Product] member nor a + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] with more than one + // [variants][google.cloud.retail.v2beta.Product.Type.VARIANT]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // All inventory information for the named + // [Product][google.cloud.retail.v2beta.Product] will be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] +// method. +message ListProductsRequest { + // Required. The parent branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use + // `default_branch` as the branch ID, to list products under the default + // branch. + // + // If the caller does not have permission to list + // [Product][google.cloud.retail.v2beta.Product]s under this branch, + // regardless of whether or not this branch exists, a PERMISSION_DENIED error + // is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. + // If unspecified, defaults to 100. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT error is returned. + int32 page_size = 2; + + // A page token + // [ListProductsResponse.next_page_token][google.cloud.retail.v2beta.ListProductsResponse.next_page_token], + // received from a previous + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; + + // A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2beta.ListProductsRequest.filter] is unset. + // * List + // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s sharing the same + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]. For example: + // `primary_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2beta.Product]s bundled in a + // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2beta.Product]. + // For example: + // `collection_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2beta.Product]s with a partibular + // type. For example: + // `type = "PRIMARY"` + // `type = "VARIANT"` + // `type = "COLLECTION"` + // + // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + // + // If the specified + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] or + // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2beta.Product] does not exist, a NOT_FOUND + // error is returned. + string filter = 4; + + // The fields of [Product][google.cloud.retail.v2beta.Product] to return in + // the responses. If not set or empty, the following fields are returned: + // + // * [Product.name][google.cloud.retail.v2beta.Product.name] + // * [Product.id][google.cloud.retail.v2beta.Product.id] + // * [Product.title][google.cloud.retail.v2beta.Product.title] + // * [Product.uri][google.cloud.retail.v2beta.Product.uri] + // * [Product.images][google.cloud.retail.v2beta.Product.images] + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // * [Product.brands][google.cloud.retail.v2beta.Product.brands] + // + // If "*" is provided, all fields are returned. + // [Product.name][google.cloud.retail.v2beta.Product.name] is always returned + // no matter what mask is set. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask read_mask = 5; +} + +// Response message for +// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] +// method. +message ListProductsResponse { + // The [Product][google.cloud.retail.v2beta.Product]s. + repeated Product products = 1; + + // A token that can be sent as + // [ListProductsRequest.page_token][google.cloud.retail.v2beta.ListProductsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for [SetInventory][] method. +message SetInventoryRequest { + // Required. The inventory information to update. The allowable fields to + // update are: + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // * [Product.availability][google.cloud.retail.v2beta.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] + // The updated inventory fields must be specified in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask]. + // + // If [SetInventoryRequest.inventory.name][] is empty or invalid, an + // INVALID_ARGUMENT error is returned. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2beta.Product] named in + // [Product.name][google.cloud.retail.v2beta.Product.name], regardless of + // whether or not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2beta.Product] to update does not + // have existing inventory information, the provided inventory information + // will be inserted. + // + // If the [Product][google.cloud.retail.v2beta.Product] to update has existing + // inventory information, the provided inventory information will be merged + // while respecting the last update time for each inventory field, using the + // provided or default value for + // [SetInventoryRequest.set_time][google.cloud.retail.v2beta.SetInventoryRequest.set_time]. + // + // The caller can replace place IDs for a subset of fulfillment types in the + // following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types and corresponding place IDs + // to update in [SetInventoryRequest.inventory.fulfillment_info][] + // + // The caller can clear all place IDs from a subset of fulfillment types in + // the following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types to clear in + // [SetInventoryRequest.inventory.fulfillment_info][] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] + // + // The last update time is recorded for the following inventory fields: + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // * [Product.availability][google.cloud.retail.v2beta.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] + // + // If a full overwrite of inventory information while ignoring timestamps is + // needed, [UpdateProduct][] should be invoked instead. + Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided + // [Product][google.cloud.retail.v2beta.Product] to update. + // + // At least one field must be provided. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask set_mask = 2; + + // The time when the request is issued, used to prevent + // out-of-order updates on inventory fields with the last update time + // recorded. If not provided, the internal system time will be used. + google.protobuf.Timestamp set_time = 3; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] with + // name [Product.name][google.cloud.retail.v2beta.Product.name] is not found, + // the inventory update will still be processed and retained for at most 1 day + // until the [Product][google.cloud.retail.v2beta.Product] is created. If set + // to false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 4; +} + +// Metadata related to the progress of the SetInventory operation. +// Currently empty because there is no meaningful metadata populated from the +// [SetInventory][] method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the [SetInventory][] +// method. +message SetInventoryResponse {} + +// Request message for [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type], such + // as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery" to be added for this + // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type]. + // Duplicate IDs will be automatically ignored. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // If the total number of place IDs exceeds 2000 for this + // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type] after + // adding, then the update will be rejected. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the AddFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesMetadata {} + +// Response of the AddFulfillmentPlacesRequest. Currently empty because +// there is no meaningful response populated from the [AddFulfillmentPlaces][] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for [AddLocalInventories][] method. +message AddLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of inventory information at difference places. Each place + // is identified by its place ID. At most 3000 inventories are allowed per + // request. + repeated LocalInventory local_inventories = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided list of + // [LocalInventory][google.cloud.retail.v2beta.LocalInventory] to update. The + // field is updated to the provided value. + // + // If a field is set while the place does not have a previous local inventory, + // the local inventory at that store is created. + // + // If a field is set while the value of that field is not provided, the + // original field value, if it exists, is deleted. + // + // If the mask is not set or set with empty paths, all inventory fields will + // be updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask add_mask = 4; + + // The time when the inventory updates are issued. Used to prevent + // out-of-order updates on local inventory fields. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the local inventory will still be processed and retained for at + // most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 6; +} + +// Metadata related to the progress of the AddLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddLocalInventories][] method. +message AddLocalInventoriesMetadata {} + +// Response of the [AddLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [AddLocalInventories][] +// method. +message AddLocalInventoriesResponse {} + +// Request message for [RemoveLocalInventories][] method. +message RemoveLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of place IDs to have their inventory deleted. + // At most 3000 place IDs are allowed per request. + repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; + + // The time when the inventory deletions are issued. Used to prevent + // out-of-order updates and deletions on local inventory fields. If not + // provided, the internal system time will be used. + google.protobuf.Timestamp remove_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the local inventory removal request will still be processed and + // retained for at most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 3; +} + +// Metadata related to the progress of the RemoveLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveLocalInventories][] method. +message RemoveLocalInventoriesMetadata {} + +// Response of the [RemoveLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [RemoveLocalInventories][] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type], + // such as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery", to be removed for this + // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type]. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp remove_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the RemoveFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the [RemoveFulfillmentPlaces][] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto new file mode 100644 index 00000000..5346f14d --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto @@ -0,0 +1,40 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "PromotionProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Promotion information. +message Promotion { + // ID of the promotion. For example, "free gift". + // + // The value must be a UTF-8 encoded string with a length limit of 128 + // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, + // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Google Merchant Center property + // [promotion](https://support.google.com/merchants/answer/7050148). + string promotion_id = 1; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto new file mode 100644 index 00000000..5ab09aa3 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto @@ -0,0 +1,80 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Metadata related to the progress of the Purge operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeMetadata {} + +// Request message for PurgeUserEvents method. +message PurgeUserEventsRequest { + // Required. The resource name of the catalog under which the events are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The filter string to specify the events to be deleted with a + // length limit of 5,000 characters. Empty string filter is not allowed. The + // eligible fields for filtering are: + // + // * `eventType`: Double quoted + // [UserEvent.event_type][google.cloud.retail.v2beta.UserEvent.event_type] + // string. + // * `eventTime`: in ISO 8601 "zulu" format. + // * `visitorId`: Double quoted string. Specifying this will delete all + // events associated with a visitor. + // * `userId`: Double quoted string. Specifying this will delete all events + // associated with a user. + // + // Examples: + // + // * Deleting all events in a time range: + // `eventTime > "2012-04-23T18:25:43.511Z" + // eventTime < "2012-04-23T18:30:43.511Z"` + // * Deleting specific eventType in time range: + // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + // * Deleting all events for a specific visitor: + // `visitorId = "visitor1024"` + // + // The filtering fields are assumed to have an implicit AND. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any user events. + bool force = 3; +} + +// Response of the PurgeUserEventsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeUserEventsResponse { + // The total count of events purged as a result of the operation. + int64 purged_events_count = 1; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto new file mode 100644 index 00000000..b8b2156a --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto @@ -0,0 +1,791 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service SearchService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" + body: "*" + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] +// method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Product][google.cloud.retail.v2beta.Product] object, over which the + // facet values are computed. Facet key is case-sensitive. + // + // Allowed facet keys when + // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] + // is not specified: + // + // * textual_field = + // * "brands" + // * "categories" + // * "genders" + // * "ageGroups" + // * "availability" + // * "colorFamilies" + // * "colors" + // * "sizes" + // * "materials" + // * "patterns" + // * "conditions" + // * "attributes.key" + // * "pickupInStore" + // * "shipToStore" + // * "sameDayDelivery" + // * "nextDayDelivery" + // * "customFulfillment1" + // * "customFulfillment2" + // * "customFulfillment3" + // * "customFulfillment4" + // * "customFulfillment5" + // * "inventory(place_id,attributes.key)" + // + // * numerical_field = + // * "price" + // * "discount" + // * "rating" + // * "ratingCount" + // * "attributes.key" + // * "inventory(place_id,price)" + // * "inventory(place_id,original_price)" + // * "inventory(place_id,attributes.key)" + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. For example, when using + // "pickupInStore" as key and set restricted values to + // ["store123", "store456"], only facets for "store123" and "store456" are + // returned. Only supported on textual fields and fulfillments. + // Maximum is 20. + // + // Must be set for the fulfillment facet keys: + // + // * pickupInStore + // + // * shipToStore + // + // * sameDayDelivery + // + // * nextDayDelivery + // + // * customFulfillment1 + // + // * customFulfillment2 + // + // * customFulfillment3 + // + // * customFulfillment4 + // + // * customFulfillment5 + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the + // "categories" facet will give only "Women > Shoe" and "Women > Dress". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 8; + + // Only get facet values that contains the given strings. For example, + // suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the + // "categories" facet will give only "Women > Shoe" and "Men > Shoe". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 9; + + // The order in which [Facet.values][] are returned. + // + // Allowed values are: + // + // * "count desc", which means order by [Facet.FacetValue.count][] + // descending. + // + // * "value desc", which means order by [Facet.FacetValue.value][] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.intervals]; + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // are sorted in the order given by + // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.restricted_values]. + string order_by = 4; + + // The query that is used to compute facet for the given facet key. + // When provided, it will override the default behavior of facet + // computation. The query syntax is the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for detail syntax and limitations. Notice that there is no limitation + // on + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // when query is specified. + // + // In the response, [FacetValue.value][] will be always "1" and + // [FacetValue.count][] will be the number of results that matches the + // query. + // + // For example, you can set a customized facet for "shipToStore", + // where + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // is "customizedShipToStore", and + // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] + // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". + // Then the facet will count the products that are both in stock and ship + // to store "123". + string query = 5; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // By default, + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // For example, suppose there are 100 products with color facet "Red" and + // 200 products with color facet "Blue". A query containing the filter + // "colorFamilies:ANY("Red")" and have "colorFamilies" as + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // will by default return the "Red" with count 100. + // + // If this field contains "colorFamilies", then the query returns both the + // "Red" with count 100 and "Blue" with count 200, because the + // "colorFamilies" key is now excluded from the filter. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined by Google + // Retail Search. It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined by + // Google Retail Search. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how Google Retail Search orders "gender" and + // "rating" facets. However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // The specifications of dynamically generated facets. + message DynamicFacetSpec { + // Enum to control DynamicFacet mode + enum Mode { + // Default value. + MODE_UNSPECIFIED = 0; + + // Disable Dynamic Facet. + DISABLED = 1; + + // Automatic mode built by Google Retail Search. + ENABLED = 2; + } + + // Mode of the DynamicFacet feature. + // Defaults to + // [Mode.DISABLED][google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode.DISABLED] + // if it's unset. + Mode mode = 1; + } + + // Boost specification to boost certain items. + message BoostSpec { + // Boost applies to products which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue": + // * (id: ANY("product_1", "product_2")) AND (colorFamilies: + // ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a product matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 10. + repeated ConditionBoostSpec condition_boost_specs = 1; + + // Whether to skip boostspec validation. If this field is set to true, + // invalid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // will be ignored and valid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // will still be applied. + optional bool skip_boost_spec_validation = 2; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. This defaults to + // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.retail.v2beta.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by Google Retail Search. + AUTO = 3; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + + // Whether to pin unexpanded results. If this field is set to true, + // unexpanded products are always at the top of the search results, followed + // by the expanded results. + bool pin_unexpanded_results = 2; + } + + // The specification for personalization. + message PersonalizationSpec { + // The personalization mode of each search request. + enum Mode { + // Default value. Defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The search mode of each search request. + enum SearchMode { + // Default value. In this case both product search and faceted search will + // be performed. Both [SearchResponse.SearchResult] and + // [SearchResponse.Facet] will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only [SearchResponse.SearchResult] will be returned. + // [SearchResponse.Facet] will not be returned, even if + // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] + // or + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] + // is set. + PRODUCT_SEARCH_ONLY = 1; + + // Only faceted search will be performed. The product search will be + // disabled. + // + // When in this mode, one or both of [SearchRequest.facet_spec][] and + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] + // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only + // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the search engine placement, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` + // This field is used to identify the serving configuration name and the set + // of models that will be used to make the search. + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. + // + // Use "default_branch" as the branch ID or leave this field empty, to search + // products under the default branch. + string branch = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Raw search query. + string query = 3; + + // Required. A unique identifier for tracking visitors. For example, this + // could be implemented with an HTTP cookie, which should be able to uniquely + // identify a visitor on a single device. This unique identifier should not + // change if the visitor logs in or out of the website. + // + // This should be the same identifier as + // [UserEvent.visitor_id][google.cloud.retail.v2beta.UserEvent.visitor_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; + + // User information. + UserInfo user_info = 5; + + // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. + // If unspecified, defaults to a reasonable value. The maximum allowed value + // is 120. Values above 120 will be coerced to 120. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 7; + + // A page token + // [SearchResponse.next_page_token][google.cloud.retail.v2beta.SearchResponse.next_page_token], + // received from a previous + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 8; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the [Product][google.cloud.retail.v2beta.Product]s + // deemed by the API as relevant) in search results. This field is only + // considered if + // [page_token][google.cloud.retail.v2beta.SearchRequest.page_token] is unset. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 offset = 9; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. Filter + // expression is case-sensitive. See more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string filter = 10; + + // The default filter that is applied when a user performs a search without + // checking any filters on the search page. + // + // The filter applied to every search request when quality improvement such as + // query expansion is needed. For example, if a query does not have enough + // results, an expanded query with + // [SearchRequest.canonical_filter][google.cloud.retail.v2beta.SearchRequest.canonical_filter] + // will be returned as a supplement of the original query. This field is + // strongly recommended to achieve high search quality. + // + // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for more details about filter syntax. + string canonical_filter = 28; + + // The order in which products are returned. Products can be ordered by + // a field in an [Product][google.cloud.retail.v2beta.Product] object. Leave + // it unset if ordered by relevance. OrderBy expression is case-sensitive. See + // more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#order). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string order_by = 11; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated FacetSpec facet_specs = 12; + + // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + // to enable dynamic facets. Do not set this field. + // + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; + + // Boost specification to boost certain products. See more details at this + // [user guide](https://cloud.google.com/retail/docs/boosting). + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] + // and [SearchRequest.boost_spec] are set, the boost conditions from both + // places are evaluated. If a search request matches multiple boost + // conditions, the final boost score is equal to the sum of the boost scores + // from all matched boost conditions. + BoostSpec boost_spec = 13; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + QueryExpansionSpec query_expansion_spec = 14; + + // The keys to fetch and rollup the matching + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s attributes, + // [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo] or + // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s attributes. + // The attributes from all the matching + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s or + // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s are merged and + // de-duplicated. Notice that rollup attributes will lead to extra query + // latency. Maximum number of keys is 30. + // + // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], a + // fulfillment type and a fulfillment ID must be provided in the format of + // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + // "pickupInStore" is fulfillment type and "store123" is the store ID. + // + // Supported keys are: + // + // * colorFamilies + // * price + // * originalPrice + // * discount + // * variantId + // * inventory(place_id,price) + // * inventory(place_id,original_price) + // * inventory(place_id,attributes.key), where key is any key in the + // [Product.inventories.attributes][] map. + // * attributes.key, where key is any key in the + // [Product.attributes][google.cloud.retail.v2beta.Product.attributes] map. + // * pickupInStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "pickup-in-store". + // * shipToStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "ship-to-store". + // * sameDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "same-day-delivery". + // * nextDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "next-day-delivery". + // * customFulfillment1.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-1". + // * customFulfillment2.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-2". + // * customFulfillment3.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-3". + // * customFulfillment4.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-4". + // * customFulfillment5.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-5". + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + repeated string variant_rollup_keys = 17; + + // The categories associated with a category page. Required for category + // navigation queries to achieve good search quality. The format should be + // the same as + // [UserEvent.page_categories][google.cloud.retail.v2beta.UserEvent.page_categories]; + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + repeated string page_categories = 23; + + // The search mode of the search request. If not specified, a single search + // request triggers both product search and faceted search. + SearchMode search_mode = 31; + + // The specification for personalization. + PersonalizationSpec personalization_spec = 32; +} + +// Response message for +// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] +// method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Product.id][google.cloud.retail.v2beta.Product.id] of the searched + // [Product][google.cloud.retail.v2beta.Product]. + string id = 1; + + // The product data snippet in the search response. Only + // [Product.name][google.cloud.retail.v2beta.Product.name] is guaranteed to + // be populated. + // + // [Product.variants][google.cloud.retail.v2beta.Product.variants] contains + // the product variants that match the search query. If there are multiple + // product variants matching the query, top 5 most relevant product variants + // are returned and ordered by relevancy. + // + // If relevancy can be deternmined, use + // [matching_variant_fields][google.cloud.retail.v2beta.SearchResponse.SearchResult.matching_variant_fields] + // to look up matched product variants fields. If relevancy cannot be + // determined, e.g. when searching "shoe" all products in a shoe product can + // be a match, 5 product variants are returned but order is meaningless. + Product product = 2; + + // The count of matched + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s. + int32 matching_variant_count = 3; + + // If a [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] matches the search query, + // this map indicates which [Product][google.cloud.retail.v2beta.Product] + // fields are matched. The key is the + // [Product.name][google.cloud.retail.v2beta.Product.name], the value is a + // field mask of the matched [Product][google.cloud.retail.v2beta.Product] + // fields. If matched attributes cannot be determined, this map will be + // empty. + // + // For example, a key "sku1" with field mask + // "products.color_info" indicates there is a match between + // "sku1" [ColorInfo][google.cloud.retail.v2beta.ColorInfo] and the query. + map matching_variant_fields = 4; + + // The rollup matching + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] attributes. The key is one + // of the + // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2beta.SearchRequest.variant_rollup_keys]. + // The values are the merged and de-duplicated + // [Product][google.cloud.retail.v2beta.Product] attributes. Notice that the + // rollup values are respect filter. For example, when filtering by + // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is + // returned. + // + // For textual and numerical attributes, the rollup values is a list of + // string or double values with type + // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if + // there are two variants with colors "red" and "blue", the rollup values + // are + // + // { key: "colorFamilies" + // value { + // list_value { + // values { string_value: "red" } + // values { string_value: "blue" } + // } + // } + // } + // + // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], the + // rollup values is a double value with type + // [google.protobuf.Value][google.protobuf.Value]. For example, + // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there + // are 10 variants in this product are available in the store "store1". + map variant_rollup_values = 5; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colorFamilies". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + } + + // The key for this facet. E.g., "colorFamilies" or "price" or + // "attributes.attr1". + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Information describing query expansion including whether expansion has + // occurred. + message QueryExpansionInfo { + // Bool describing whether query expansion has occurred. + bool expanded_query = 1; + + // Number of pinned results. This field will only be set when expansion + // happens and + // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] + // is set to true. + int64 pinned_result_count = 2; + } + + // A list of matched items. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.retail.v2beta.SearchResponse.results] + // returned by pagination may be less than the + // [total_size][google.cloud.retail.v2beta.SearchResponse.total_size] that + // matches. + int32 total_size = 3; + + // If spell correction applies, the corrected query. Otherwise, empty. + string corrected_query = 4; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this + // search, which enables accurate attribution of search model performance. + string attribution_token = 5; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.retail.v2beta.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 6; + + // Query expansion information for the returned results. + QueryExpansionInfo query_expansion_info = 7; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search will be performed, and only + // [redirect_uri][google.cloud.retail.v2beta.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] + // will be set in the response. + string redirect_uri = 10; + + // The fully qualified resource name of applied + // [controls](https://cloud.google.com/retail/docs/serving-control-rules). + repeated string applied_controls = 12; + + // The invalid + // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto new file mode 100644 index 00000000..20112e61 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto @@ -0,0 +1,247 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configures metadata that is used to generate serving time results (e.g. +// search results or recommendation predictions). +// The ServingConfig is passed in the search and predict request and together +// with the Catalog.default_branch, generates results. +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // Immutable. Fully qualified name + // projects/*/locations/global/catalogs/*/servingConfig/* + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable serving config display name. Used in Retail + // UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // The id of the model to use at serving time. + // Currently only RecommendationModels are supported: + // https://cloud.google.com/retail/recommendations-ai/docs/create-models + // Can be changed but only to a compatible model (e.g. + // others-you-may-like CTR to others-you-may-like CVR). + // + // Required when + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string model_id = 3; + + // How much price ranking we want in serving results. + // Price reranking causes product items with a similar + // recommendation probability to be ordered by price, with the + // highest-priced items first. This setting could result in a decrease in + // click-through and conversion rates. + // Allowed values are: + // + // * 'no-price-reranking' + // * 'low-price-raranking' + // * 'medium-price-reranking' + // * 'high-price-reranking' + // + // If not specified, we choose default based on model type. Default value: + // 'no-price-reranking'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string price_reranking_level = 4; + + // Facet specifications for faceted search. If empty, no facets are returned. + // The ids refer to the ids of [Control][google.cloud.retail.v2beta.Control] + // resources with only the Facet control set. These controls are assumed to be + // in the same [Catalog][google.cloud.retail.v2beta.Catalog] as the + // [ServingConfig][google.cloud.retail.v2beta.ServingConfig]. + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string facet_control_ids = 5; + + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; + + // Condition boost specifications. If a product matches multiple conditions + // in the specifications, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 100. + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] + // and [SearchRequest.boost_spec] are set, the boost conditions from both + // places are evaluated. If a search request matches multiple boost + // conditions, the final boost score is equal to the sum of the boost scores + // from all matched boost conditions. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string boost_control_ids = 7; + + // Condition filter specifications. If a product matches multiple conditions + // in the specifications, filters from these specifications are all + // applied and combined via the AND operator. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string filter_control_ids = 9; + + // Condition redirect specifications. Only the first triggered redirect action + // is applied, even if multiple apply. Maximum number of specifications is + // 1000. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string redirect_control_ids = 10; + + // Condition synonyms specifications. If multiple syonyms conditions match, + // all matching synonyms control in the list will execute. Order of controls + // in the list will not matter. Maximum number of specifications is + // 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string twoway_synonyms_control_ids = 18; + + // Condition oneway synonyms specifications. If multiple oneway synonyms + // conditions match, all matching oneway synonyms controls in the list will + // execute. Order of controls in the list will not matter. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string oneway_synonyms_control_ids = 12; + + // Condition do not associate specifications. If multiple do not associate + // conditions match, all matching do not associate controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string do_not_associate_control_ids = 13; + + // Condition replacement specifications. + // - Applied according to the order in the list. + // - A previously replaced term can not be re-replaced. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string replacement_control_ids = 14; + + // Condition ignore specifications. If multiple ignore + // conditions match, all matching ignore controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string ignore_control_ids = 15; + + // How much diversity to use in recommendation model results e.g. + // 'medium-diversity' or 'high-diversity'. Currently supported values: + // + // * 'no-diversity' + // * 'low-diversity' + // * 'medium-diversity' + // * 'high-diversity' + // * 'auto-diversity' + // + // If not specified, we choose default based on recommendation model + // type. Default value: 'no-diversity'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string diversity_level = 8; + + // Whether to add additional category filters on the 'similar-items' model. + // If not specified, we enable it by default. + // Allowed values are: + // + // * 'no-category-match': No additional filtering of original results from + // the model and the customer's filters. + // * 'relaxed-category-match': Only keep results with categories that match + // at least one item categories in the PredictRequests's context item. + // * If customer also sends filters in the PredictRequest, then the results + // will satisfy both conditions (user given and category match). + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string enable_category_filter_level = 16; + + // Required. Immutable. Specifies the solution types that a serving config can + // be associated with. Currently we support setting only one type of solution. + repeated SolutionType solution_types = 19 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto new file mode 100644 index 00000000..e56c28ac --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto @@ -0,0 +1,240 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/serving_config.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for modifying ServingConfig. +service ServingConfigService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a ServingConfig. + // + // A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s + // are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise + // a FAILED_PRECONDITION error is returned. + rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + body: "serving_config" + }; + option (google.api.method_signature) = + "parent,serving_config,serving_config_id"; + } + + // Deletes a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc DeleteServingConfig(DeleteServingConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a ServingConfig. + rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + patch: "/v2beta/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + body: "serving_config" + }; + option (google.api.method_signature) = "serving_config,update_mask"; + } + + // Gets a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all ServingConfigs linked to this catalog. + rpc ListServingConfigs(ListServingConfigsRequest) + returns (ListServingConfigsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Enables a Control on the specified ServingConfig. + // The control is added in the last position of the list of controls + // it belongs to (e.g. if it's a facet spec control it will be applied + // in the last position of servingConfig.facetSpecIds) + // Returns a ALREADY_EXISTS error if the control has already been applied. + // Returns a FAILED_PRECONDITION error if the addition could exceed maximum + // number of control allowed for that type of control. + rpc AddControl(AddControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } + + // Disables a Control on the specified ServingConfig. + // The control is removed from the ServingConfig. + // Returns a NOT_FOUND error if the Control is not enabled for the + // ServingConfig. + rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } +} + +// Request for CreateServingConfig method. +message CreateServingConfigRequest { + // Required. Full resource name of parent. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The ServingConfig to create. + ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the ServingConfig, which will become the final + // component of the ServingConfig's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateServingConfig method. +message UpdateServingConfigRequest { + // Required. The ServingConfig to update. + ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [ServingConfig][google.cloud.retail.v2beta.ServingConfig] to update. The + // following are NOT supported: + // + // * [ServingConfig.name][google.cloud.retail.v2beta.ServingConfig.name] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteServingConfig method. +message DeleteServingConfigRequest { + // Required. The resource name of the ServingConfig to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for GetServingConfig method. +message GetServingConfigRequest { + // Required. The resource name of the ServingConfig to get. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for ListServingConfigs method. +message ListServingConfigsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 100. If a value greater than 100 is provided, at most 100 results are + // returned. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListServingConfigs` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListServingConfigs method. +message ListServingConfigsResponse { + // All the ServingConfigs for a given catalog. + repeated ServingConfig serving_configs = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request for AddControl method. +message AddControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config - if id is not found a NOT_FOUND error is returned. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for RemoveControl method. +message RemoveControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto new file mode 100644 index 00000000..e2175801 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto @@ -0,0 +1,342 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// UserEvent captures all metadata information Retail API needs to know about +// how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // * `add-to-cart`: Products being added to cart. + // * `category-page-view`: Special pages such as sale or promotion pages + // viewed. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed. + // * `promotion-offered`: Promotion is offered to a user. + // * `promotion-not-offered`: Promotion is not offered to a user. + // * `purchase-complete`: User finishing a purchase. + // * `search`: Product search. + // * `shopping-cart-page-view`: User viewing a shopping cart. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A unique identifier for tracking visitors. + // + // For example, this could be implemented with an HTTP cookie, which should be + // able to uniquely identify a visitor on a single device. This unique + // identifier should not change if the visitor log in/out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analystics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the sesion_id: + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // visitor_id as prefix. + string session_id = 21; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.retail.v2beta.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups (e.g. using Retail API, using different + // recommendation models). + repeated string experiment_ids = 4; + + // Highly recommended for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be a valid + // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] + // for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. + // The value must be a valid + // [SearchResponse.attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] + // for user events that are the result of + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // This token enables us to accurately attribute page view or purchase back to + // the event and the particular predict response containing this + // clicked/purchased product. If user clicks on product K in the + // recommendation results, pass + // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] + // as a URL parameter to product K's page. When recording events on product + // K's page, log the + // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] + // to this field. + string attribution_token = 5; + + // The main product details related to the event. + // + // This field is required for the following event types: + // + // * `add-to-cart` + // * `detail-page-view` + // * `purchase-complete` + // * `search` + // + // In a `search` event, this field represents the products returned to the end + // user on the current page (the end user may have not finished browsing the + // whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [product_details][google.cloud.retail.v2beta.UserEvent.product_details] is + // desired. The end user may have not finished browsing the whole page yet. + repeated ProductDetail product_details = 6; + + // The main auto-completion details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionDetail completion_detail = 22; + + // Extra user event features to include in the recommendation model. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Retail API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // traffic_channel, which is how a user arrives at the site. Users can arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 7; + + // The ID or name of the associated shopping cart. This ID is used + // to associate multiple items added or present in the cart before purchase. + // + // This can only be set for `add-to-cart`, `purchase-complete`, or + // `shopping-cart-page-view` events. + string cart_id = 8; + + // A transaction represents the entire purchase transaction. + // + // Required for `purchase-complete` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + PurchaseTransaction purchase_transaction = 9; + + // The user's search query. + // + // See [SearchRequest.query][google.cloud.retail.v2beta.SearchRequest.query] + // for definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 10; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. + // + // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 16; + + // The order in which products are returned. + // + // See + // [SearchRequest.order_by][google.cloud.retail.v2beta.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 17; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See [SearchRequest.offset][google.cloud.retail.v2beta.SearchRequest.offset] + // for definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + int32 offset = 18; + + // The categories associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + // + // Required for `category-page-view` events. At least one of + // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string page_categories = 11; + + // User information. + UserInfo user_info = 12; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 13; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string referrer_uri = 14; + + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string page_view_id = 15; +} + +// Detailed product information associated with a user event. +message ProductDetail { + // Required. [Product][google.cloud.retail.v2beta.Product] information. + // + // Required field(s): + // + // * [Product.id][google.cloud.retail.v2beta.Product.id] + // + // Optional override field(s): + // + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // + // If any supported optional fields are provided, we will treat them as a full + // override when looking up product information from the catalog. Thus, it is + // important to ensure that the overriding fields are accurate and + // complete. + // + // All other product fields are ignored and instead populated via catalog + // lookup after event ingestion. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Quantity of the product associated with the user event. + // + // For example, this field will be 2 if two products are added to the shopping + // cart for `purchase-complete` event. Required for `add-to-cart` and + // `purchase-complete` event types. + google.protobuf.Int32Value quantity = 2; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionDetail { + // Completion attribution token in + // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2beta.CompleteQueryResponse.attribution_token]. + string completion_attribution_token = 1; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion]. + string selected_suggestion = 2; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion] + // position, starting from 0. + int32 selected_position = 3; +} + +// A transaction represents the entire purchase transaction. +message PurchaseTransaction { + // The transaction ID with a length limit of 128 characters. + string id = 1; + + // Required. Total non-zero revenue or grand total associated with the + // transaction. This value include shipping, tax, or other adjustments to + // total revenue that you want to include as part of your revenue + // calculations. + float revenue = 2 [(google.api.field_behavior) = REQUIRED]; + + // All the taxes associated with the transaction. + float tax = 3; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = + // [revenue][google.cloud.retail.v2beta.PurchaseTransaction.revenue] - + // [tax][google.cloud.retail.v2beta.PurchaseTransaction.tax] - + // [cost][google.cloud.retail.v2beta.PurchaseTransaction.cost] + float cost = 4; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto new file mode 100644 index 00000000..ab7a0b35 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto @@ -0,0 +1,190 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; +import "google/cloud/retail/v2beta/purge_config.proto"; +import "google/cloud/retail/v2beta/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for ingesting end user actions on the customer website. +service UserEventService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" + body: "user_event" + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Retail API JavaScript pixel and Google Tag + // Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }; + } + + // Deletes permanently all user events specified by the filter provided. + // Depending on the number of events specified by the filter, this operation + // could take hours or days to complete. To test a filter, use the list + // command first. + rpc PurgeUserEvents(PurgeUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.PurgeUserEventsResponse" + metadata_type: "google.cloud.retail.v2beta.PurgeMetadata" + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // Operation.response is of type ImportResponse. Note that it is + // possible for a subset of the items to be successfully inserted. + // Operation.metadata is of type ImportMetadata. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ImportUserEventsResponse" + metadata_type: "google.cloud.retail.v2beta.ImportMetadata" + }; + } + + // Starts a user event rejoin operation with latest product catalog. Events + // will not be annotated with detailed product information if product is + // missing from the catalog at the time the user event is ingested, and these + // events are stored as unjoined events with a limited usage on training and + // serving. This method can be used to start a join operation on specified + // events with latest version of product catalog. It can also be used to + // correct events joined with the wrong product catalog. A rejoin operation + // can take hours or days to complete. + rpc RejoinUserEvents(RejoinUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "RejoinUserEventsResponse" + metadata_type: "RejoinUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User event to write. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent catalog name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // The URL including cgi-parameters but excluding the hash fragment with a + // length limit of 5,000 characters. This is often more useful than the + // referer URL, because many browsers only send the domain for 3rd party + // requests. + string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + int64 ets = 4; +} + +// Request message for RejoinUserEvents method. +message RejoinUserEventsRequest { + // The scope of user events to be rejoined with the latest product catalog. + // If the rejoining aims at reducing number of unjoined events, set + // UserEventRejoinScope to UNJOINED_EVENTS. + // If the rejoining aims at correcting product catalog information in joined + // events, set UserEventRejoinScope to JOINED_EVENTS. + // If all events needs to be rejoined, set UserEventRejoinScope to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. + enum UserEventRejoinScope { + // Rejoin all events with the latest product catalog, including both joined + // events and unjoined events. + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; + + // Only rejoin joined events with the latest product catalog. + JOINED_EVENTS = 1; + + // Only rejoin unjoined events with the latest product catalog. + UNJOINED_EVENTS = 2; + } + + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the user event rejoin to define the scope and range of the user + // events to be rejoined with the latest product catalog. Defaults to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + // invalid integer value. + UserEventRejoinScope user_event_rejoin_scope = 2; +} + +// Response message for RejoinUserEvents method. +message RejoinUserEventsResponse { + // Number of user events that were joined with latest product catalog. + int64 rejoined_user_events_count = 1; +} + +// Metadata for RejoinUserEvents method. +message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000..553e7103 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2beta_generated_CatalogService_AddCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to add. + */ + // const catalogAttribute = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callAddCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.addCatalogAttribute(request); + console.log(response); + } + + callAddCatalogAttribute(); + // [END retail_v2beta_generated_CatalogService_AddCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js new file mode 100644 index 00000000..b6c393bd --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_CatalogService_GetAttributesConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetAttributesConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getAttributesConfig(request); + console.log(response); + } + + callGetAttributesConfig(); + // [END retail_v2beta_generated_CatalogService_GetAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js new file mode 100644 index 00000000..886e118a --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_CatalogService_GetCompletionConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetCompletionConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getCompletionConfig(request); + console.log(response); + } + + callGetCompletionConfig(); + // [END retail_v2beta_generated_CatalogService_GetCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js new file mode 100644 index 00000000..11ab8856 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js @@ -0,0 +1,58 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2beta_generated_CatalogService_GetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.getDefaultBranch(request); + console.log(response); + } + + callGetDefaultBranch(); + // [END retail_v2beta_generated_CatalogService_GetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js new file mode 100644 index 00000000..a72872cb --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_CatalogService_ListCatalogs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The account resource name with an associated location. + * If the caller does not have permission to list + * Catalog google.cloud.retail.v2beta.Catalog s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Catalog google.cloud.retail.v2beta.Catalog s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListCatalogsResponse.next_page_token google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token, + * received from a previous + * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callListCatalogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCatalogs(); + // [END retail_v2beta_generated_CatalogService_ListCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000..b6d4473a --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, key) { + // [START retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name key of the + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to remove. + */ + // const key = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callRemoveCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + key, + }; + + // Run request + const response = await retailClient.removeCatalogAttribute(request); + console.log(response); + } + + callRemoveCatalogAttribute(); + // [END retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000..42548549 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.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(attributesConfig, catalogAttribute) { + // [START retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The updated + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute. + */ + // const catalogAttribute = {} + /** + * Indicates which fields in the provided + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to update. + * The following are NOT supported: + * * CatalogAttribute.key google.cloud.retail.v2beta.CatalogAttribute.key + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callReplaceCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.replaceCatalogAttribute(request); + console.log(response); + } + + callReplaceCatalogAttribute(); + // [END retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js new file mode 100644 index 00000000..11f667df --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2beta_generated_CatalogService_SetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * The final component of the resource name of a branch. + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * If there are no sufficient active products in the targeted branch and + * force google.cloud.retail.v2beta.SetDefaultBranchRequest.force is not + * set, a FAILED_PRECONDITION error is returned. + */ + // const branchId = 'abc123' + /** + * Some note on this request, this can be retrieved by + * CatalogService.GetDefaultBranch google.cloud.retail.v2beta.CatalogService.GetDefaultBranch + * before next valid default branch set occurs. + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const note = 'abc123' + /** + * If set to true, it permits switching to a branch with + * branch_id google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id + * even if it has no sufficient active products. + */ + // const force = true + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callSetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.setDefaultBranch(request); + console.log(response); + } + + callSetDefaultBranch(); + // [END retail_v2beta_generated_CatalogService_SetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js new file mode 100644 index 00000000..dee9a094 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.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(attributesConfig) { + // [START retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The + * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. + */ + // const attributesConfig = {} + /** + * Indicates which fields in the provided + * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. + * The following is the only supported field: + * * AttributesConfig.catalog_attributes google.cloud.retail.v2beta.AttributesConfig.catalog_attributes + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateAttributesConfig() { + // Construct request + const request = { + attributesConfig, + }; + + // Run request + const response = await retailClient.updateAttributesConfig(request); + console.log(response); + } + + callUpdateAttributesConfig(); + // [END retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js new file mode 100644 index 00000000..3f75b996 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.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(catalog) { + // [START retail_v2beta_generated_CatalogService_UpdateCatalog_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Catalog google.cloud.retail.v2beta.Catalog to update. + * If the caller does not have permission to update the + * Catalog google.cloud.retail.v2beta.Catalog, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the Catalog google.cloud.retail.v2beta.Catalog to update does not + * exist, a NOT_FOUND error is returned. + */ + // const catalog = {} + /** + * Indicates which fields in the provided + * Catalog google.cloud.retail.v2beta.Catalog to update. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCatalog() { + // Construct request + const request = { + catalog, + }; + + // Run request + const response = await retailClient.updateCatalog(request); + console.log(response); + } + + callUpdateCatalog(); + // [END retail_v2beta_generated_CatalogService_UpdateCatalog_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js new file mode 100644 index 00000000..d3c451f3 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(completionConfig) { + // [START retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The + * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. + * If the caller does not have permission to update the + * CompletionConfig google.cloud.retail.v2beta.CompletionConfig, then a + * PERMISSION_DENIED error is returned. + * If the CompletionConfig google.cloud.retail.v2beta.CompletionConfig to + * update does not exist, a NOT_FOUND error is returned. + */ + // const completionConfig = {} + /** + * Indicates which fields in the provided + * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. + * The following are the only supported fields: + * * CompletionConfig.matching_order google.cloud.retail.v2beta.CompletionConfig.matching_order + * * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions + * * CompletionConfig.min_prefix_length google.cloud.retail.v2beta.CompletionConfig.min_prefix_length + * * CompletionConfig.auto_learning google.cloud.retail.v2beta.CompletionConfig.auto_learning + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCompletionConfig() { + // Construct request + const request = { + completionConfig, + }; + + // Run request + const response = await retailClient.updateCompletionConfig(request); + console.log(response); + } + + callUpdateCompletionConfig(); + // [END retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js new file mode 100644 index 00000000..28957ff1 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js @@ -0,0 +1,117 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog, query) { + // [START retail_v2beta_generated_CompletionService_CompleteQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Catalog for which the completion is performed. + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * Required. The query used to generate suggestions. + * The maximum number of allowed characters is 255. + */ + // const query = 'abc123' + /** + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see Tags for + * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + */ + // const languageCodes = 'abc123' + /** + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * Supported formats: + * * `UNKNOWN_DEVICE_TYPE` + * * `DESKTOP` + * * `MOBILE` + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + */ + // const deviceType = 'abc123' + /** + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * CompletionService.ImportCompletionData google.cloud.retail.v2beta.CompletionService.ImportCompletionData. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * Current supported values: + * * user-data + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + */ + // const dataset = 'abc123' + /** + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions. + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + catalog, + query, + }; + + // Run request + const response = await retailClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END retail_v2beta_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js new file mode 100644 index 00000000..046aa015 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.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, inputConfig) { + // [START retail_v2beta_generated_CompletionService_ImportCompletionData_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog which the suggestions dataset belongs to. + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callImportCompletionData() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importCompletionData(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportCompletionData(); + // [END retail_v2beta_generated_CompletionService_ImportCompletionData_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js new file mode 100644 index 00000000..670ed9d8 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.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, control, controlId) { + // [START retail_v2beta_generated_ControlService_CreateControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of parent catalog. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Required. The Control to create. + */ + // const control = {} + /** + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callCreateControl() { + // Construct request + const request = { + parent, + control, + controlId, + }; + + // Run request + const response = await retailClient.createControl(request); + console.log(response); + } + + callCreateControl(); + // [END retail_v2beta_generated_ControlService_CreateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js new file mode 100644 index 00000000..fa617382 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ControlService_DeleteControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callDeleteControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteControl(request); + console.log(response); + } + + callDeleteControl(); + // [END retail_v2beta_generated_ControlService_DeleteControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js new file mode 100644 index 00000000..dcc21c72 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ControlService_GetControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callGetControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getControl(request); + console.log(response); + } + + callGetControl(); + // [END retail_v2beta_generated_ControlService_GetControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js new file mode 100644 index 00000000..5de3859c --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_ControlService_ListControls_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + /** + * Optional. A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2beta.ListControlsRequest.filter is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + */ + // const filter = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callListControls() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listControlsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListControls(); + // [END retail_v2beta_generated_ControlService_ListControls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js new file mode 100644 index 00000000..3bc73051 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(control) { + // [START retail_v2beta_generated_ControlService_UpdateControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Control to update. + */ + // const control = {} + /** + * Indicates which fields in the provided + * Control google.cloud.retail.v2beta.Control to update. The following are + * NOT supported: + * * Control.name google.cloud.retail.v2beta.Control.name + * If not set or empty, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callUpdateControl() { + // Construct request + const request = { + control, + }; + + // Run request + const response = await retailClient.updateControl(request); + console.log(response); + } + + callUpdateControl(); + // [END retail_v2beta_generated_ControlService_UpdateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js b/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js new file mode 100644 index 00000000..38b9394c --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js @@ -0,0 +1,161 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, userEvent) { + // [START retail_v2beta_generated_PredictionService_Predict_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see Managing + * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + */ + // const placement = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + */ + // const userEvent = {} + /** + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + */ + // const pageSize = 1234 + /** + * The previous PredictResponse.next_page_token. + */ + // const pageToken = 'abc123' + /** + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * Examples: + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + */ + // const filter = 'abc123' + /** + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + */ + // const validateOnly = true + /** + * Additional domain specific parameters for the predictions. + * Allowed values: + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + */ + // const params = 1234 + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + + // Imports the Retail library + const {PredictionServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new PredictionServiceClient(); + + async function callPredict() { + // Construct request + const request = { + placement, + userEvent, + }; + + // Run request + const response = await retailClient.predict(request); + console.log(response); + } + + callPredict(); + // [END retail_v2beta_generated_PredictionService_Predict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js new file mode 100644 index 00000000..f25e375d --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type. + * Duplicate IDs will be automatically ignored. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * If the total number of place IDs exceeds 2000 for this + * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type after + * adding, then the update will be rejected. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddFulfillmentPlaces(); + // [END retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js new file mode 100644 index 00000000..827fb0fe --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js @@ -0,0 +1,100 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, localInventories) { + // [START retail_v2beta_generated_ProductService_AddLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + */ + // const localInventories = 1234 + /** + * Indicates which inventory fields in the provided list of + * LocalInventory google.cloud.retail.v2beta.LocalInventory to update. The + * field is updated to the provided value. + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const addMask = {} + /** + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddLocalInventories() { + // Construct request + const request = { + product, + localInventories, + }; + + // Run request + const [operation] = await retailClient.addLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddLocalInventories(); + // [END retail_v2beta_generated_ProductService_AddLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js new file mode 100644 index 00000000..b6387d2e --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, product, productId) { + // [START retail_v2beta_generated_ProductService_CreateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + */ + // const parent = 'abc123' + /** + * Required. The Product google.cloud.retail.v2beta.Product to create. + */ + // const product = {} + /** + * Required. The ID to use for the + * Product google.cloud.retail.v2beta.Product, which will become the final + * component of the Product.name google.cloud.retail.v2beta.Product.name. + * If the caller does not have permission to create the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * This field must be unique among all + * Product google.cloud.retail.v2beta.Product s with the same + * parent google.cloud.retail.v2beta.CreateProductRequest.parent. + * Otherwise, an ALREADY_EXISTS error is returned. + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const productId = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + productId, + }; + + // Run request + const response = await retailClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END retail_v2beta_generated_ProductService_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js new file mode 100644 index 00000000..95f4548f --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_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(name) { + // [START retail_v2beta_generated_ProductService_DeleteProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to delete the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2beta.Product to delete does not + * exist, a NOT_FOUND error is returned. + * The Product google.cloud.retail.v2beta.Product to delete can neither be + * a + * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION + * Product google.cloud.retail.v2beta.Product member nor a + * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY + * Product google.cloud.retail.v2beta.Product with more than one + * variants google.cloud.retail.v2beta.Product.Type.VARIANT. Otherwise, an + * INVALID_ARGUMENT error is returned. + * All inventory information for the named + * Product google.cloud.retail.v2beta.Product will be deleted. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END retail_v2beta_generated_ProductService_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js new file mode 100644 index 00000000..d0520d7e --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ProductService_GetProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the requested Product google.cloud.retail.v2beta.Product does not + * exist, a NOT_FOUND error is returned. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END retail_v2beta_generated_ProductService_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js new file mode 100644 index 00000000..f7fe86da --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js @@ -0,0 +1,93 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2beta_generated_ProductService_ImportProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. + */ + // const errorsConfig = {} + /** + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + */ + // const updateMask = {} + /** + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * Only supported when + * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode + * is set to `FULL`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callImportProducts() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProducts(); + // [END retail_v2beta_generated_ProductService_ImportProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js new file mode 100644 index 00000000..d4971483 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js @@ -0,0 +1,132 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_ProductService_ListProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * If the caller does not have permission to list + * Product google.cloud.retail.v2beta.Product s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Product google.cloud.retail.v2beta.Product s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT error is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListProductsResponse.next_page_token google.cloud.retail.v2beta.ListProductsResponse.next_page_token, + * received from a previous + * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2beta.ListProductsRequest.filter is unset. + * * List + * Product.Type.VARIANT google.cloud.retail.v2beta.Product.Type.VARIANT + * Product google.cloud.retail.v2beta.Product s sharing the same + * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY + * Product google.cloud.retail.v2beta.Product. For example: + * `primary_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2beta.Product s bundled in a + * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION + * Product google.cloud.retail.v2beta.Product. + * For example: + * `collection_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2beta.Product s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * If the specified + * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY + * Product google.cloud.retail.v2beta.Product or + * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION + * Product google.cloud.retail.v2beta.Product does not exist, a NOT_FOUND + * error is returned. + */ + // const filter = 'abc123' + /** + * The fields of Product google.cloud.retail.v2beta.Product to return in + * the responses. If not set or empty, the following fields are returned: + * * Product.name google.cloud.retail.v2beta.Product.name + * * Product.id google.cloud.retail.v2beta.Product.id + * * Product.title google.cloud.retail.v2beta.Product.title + * * Product.uri google.cloud.retail.v2beta.Product.uri + * * Product.images google.cloud.retail.v2beta.Product.images + * * Product.price_info google.cloud.retail.v2beta.Product.price_info + * * Product.brands google.cloud.retail.v2beta.Product.brands + * If "*" is provided, all fields are returned. + * Product.name google.cloud.retail.v2beta.Product.name is always returned + * no matter what mask is set. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const readMask = {} + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END retail_v2beta_generated_ProductService_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000..3163edcb --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js @@ -0,0 +1,111 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveFulfillmentPlaces(); + // [END retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js new file mode 100644 index 00000000..a61bac1d --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, placeIds) { + // [START retail_v2beta_generated_ProductService_RemoveLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + */ + // const placeIds = 'abc123' + /** + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveLocalInventories() { + // Construct request + const request = { + product, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveLocalInventories(); + // [END retail_v2beta_generated_ProductService_RemoveLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js new file mode 100644 index 00000000..ac7ceeff --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js @@ -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 +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inventory) { + // [START retail_v2beta_generated_ProductService_SetInventory_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The inventory information to update. The allowable fields to + * update are: + * * Product.price_info google.cloud.retail.v2beta.Product.price_info + * * Product.availability google.cloud.retail.v2beta.Product.availability + * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info + * The updated inventory fields must be specified in + * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask. + * If SetInventoryRequest.inventory.name is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2beta.Product named in + * Product.name google.cloud.retail.v2beta.Product.name, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2beta.Product to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * If the Product google.cloud.retail.v2beta.Product to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * SetInventoryRequest.set_time google.cloud.retail.v2beta.SetInventoryRequest.set_time. + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in SetInventoryRequest.inventory.fulfillment_info + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types to clear in + * SetInventoryRequest.inventory.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids + * The last update time is recorded for the following inventory fields: + * * Product.price_info google.cloud.retail.v2beta.Product.price_info + * * Product.availability google.cloud.retail.v2beta.Product.availability + * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info + * If a full overwrite of inventory information while ignoring timestamps is + * needed, UpdateProduct should be invoked instead. + */ + // const inventory = {} + /** + * Indicates which inventory fields in the provided + * Product google.cloud.retail.v2beta.Product to update. + * At least one field must be provided. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const setMask = {} + /** + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + */ + // const setTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product with + * name Product.name google.cloud.retail.v2beta.Product.name is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the Product google.cloud.retail.v2beta.Product is created. If set + * to false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callSetInventory() { + // Construct request + const request = { + inventory, + }; + + // Run request + const [operation] = await retailClient.setInventory(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInventory(); + // [END retail_v2beta_generated_ProductService_SetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js new file mode 100644 index 00000000..ed319228 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START retail_v2beta_generated_ProductService_UpdateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The product to update/create. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2beta.Product to update does not + * exist and + * allow_missing google.cloud.retail.v2beta.UpdateProductRequest.allow_missing + * is not set, a NOT_FOUND error is returned. + */ + // const product = {} + /** + * Indicates which fields in the provided + * Product google.cloud.retail.v2beta.Product to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, a new Product google.cloud.retail.v2beta.Product will be + * created. In this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await retailClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END retail_v2beta_generated_ProductService_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js b/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js new file mode 100644 index 00000000..62f1df1e --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js @@ -0,0 +1,261 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, visitorId) { + // [START retail_v2beta_generated_SearchService_Search_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + */ + // const placement = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + */ + // const query = 'abc123' + /** + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * This should be the same identifier as + * UserEvent.visitor_id google.cloud.retail.v2beta.UserEvent.visitor_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * User information. + */ + // const userInfo = {} + /** + * Maximum number of Product google.cloud.retail.v2beta.Product s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * SearchResponse.next_page_token google.cloud.retail.v2beta.SearchResponse.next_page_token, + * received from a previous + * SearchService.Search google.cloud.retail.v2beta.SearchService.Search + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.retail.v2beta.SearchService.Search + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the Product google.cloud.retail.v2beta.Product s + * deemed by the API as relevant) in search results. This field is only + * considered if + * page_token google.cloud.retail.v2beta.SearchRequest.page_token is unset. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const filter = 'abc123' + /** + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * SearchRequest.canonical_filter google.cloud.retail.v2beta.SearchRequest.canonical_filter + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * See SearchRequest.filter google.cloud.retail.v2beta.SearchRequest.filter + * for more details about filter syntax. + */ + // const canonicalFilter = 'abc123' + /** + * The order in which products are returned. Products can be ordered by + * a field in an Product google.cloud.retail.v2beta.Product object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#order). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const orderBy = 'abc123' + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain products. See more details at this + * user guide (https://cloud.google.com/retail/docs/boosting). + * Notice that if both + * ServingConfig.boost_control_ids google.cloud.retail.v2beta.ServingConfig.boost_control_ids + * and SearchRequest.boost_spec are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + */ + // const boostSpec = {} + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). + */ + // const queryExpansionSpec = {} + /** + * The keys to fetch and rollup the matching + * variant google.cloud.retail.v2beta.Product.Type.VARIANT + * Product google.cloud.retail.v2beta.Product s attributes, + * FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo or + * LocalInventory google.cloud.retail.v2beta.LocalInventory s attributes. + * The attributes from all the matching + * variant google.cloud.retail.v2beta.Product.Type.VARIANT + * Product google.cloud.retail.v2beta.Product s or + * LocalInventory google.cloud.retail.v2beta.LocalInventory s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * For FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * Supported keys are: + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * Product.inventories.attributes map. + * * attributes.key, where key is any key in the + * Product.attributes google.cloud.retail.v2beta.Product.attributes map. + * * pickupInStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "pickup-in-store". + * * shipToStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-1". + * * customFulfillment2.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-2". + * * customFulfillment3.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-3". + * * customFulfillment4.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-4". + * * customFulfillment5.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-5". + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + */ + // const variantRollupKeys = 'abc123' + /** + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * UserEvent.page_categories google.cloud.retail.v2beta.UserEvent.page_categories; + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : "Sales > 2017 Black Friday Deals". + */ + // const pageCategories = 'abc123' + /** + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + */ + // const searchMode = {} + /** + * The specification for personalization. + */ + // const personalizationSpec = {} + + // Imports the Retail library + const {SearchServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + placement, + visitorId, + }; + + // Run request + const iterable = await retailClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END retail_v2beta_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js new file mode 100644 index 00000000..9086bb91 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2beta_generated_ServingConfigService_AddControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callAddControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.addControl(request); + console.log(response); + } + + callAddControl(); + // [END retail_v2beta_generated_ServingConfigService_AddControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js new file mode 100644 index 00000000..fc8ba733 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.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, servingConfig, servingConfigId) { + // [START retail_v2beta_generated_ServingConfigService_CreateServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of parent. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Required. The ServingConfig to create. + */ + // const servingConfig = {} + /** + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const servingConfigId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callCreateServingConfig() { + // Construct request + const request = { + parent, + servingConfig, + servingConfigId, + }; + + // Run request + const response = await retailClient.createServingConfig(request); + console.log(response); + } + + callCreateServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_CreateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000..c9202725 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callDeleteServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteServingConfig(request); + console.log(response); + } + + callDeleteServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js new file mode 100644 index 00000000..be98fd45 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ServingConfigService_GetServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callGetServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getServingConfig(request); + console.log(response); + } + + callGetServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_GetServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000..7a517f3e --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.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 retail_v2beta_generated_ServingConfigService_ListServingConfigs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callListServingConfigs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listServingConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServingConfigs(); + // [END retail_v2beta_generated_ServingConfigService_ListServingConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js new file mode 100644 index 00000000..314b82f9 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2beta_generated_ServingConfigService_RemoveControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callRemoveControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.removeControl(request); + console.log(response); + } + + callRemoveControl(); + // [END retail_v2beta_generated_ServingConfigService_RemoveControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js new file mode 100644 index 00000000..f948464a --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig) { + // [START retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ServingConfig to update. + */ + // const servingConfig = {} + /** + * Indicates which fields in the provided + * ServingConfig google.cloud.retail.v2beta.ServingConfig to update. The + * following are NOT supported: + * * ServingConfig.name google.cloud.retail.v2beta.ServingConfig.name + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callUpdateServingConfig() { + // Construct request + const request = { + servingConfig, + }; + + // Run request + const response = await retailClient.updateServingConfig(request); + console.log(response); + } + + callUpdateServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json b/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json new file mode 100644 index 00000000..8e89b650 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json @@ -0,0 +1,2131 @@ +{ + "clientLibrary": { + "name": "nodejs-retail", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.retail.v2beta", + "version": "v2beta" + } + ] + }, + "snippets": [ + { + "regionTag": "retail_v2beta_generated_CatalogService_ListCatalogs_async", + "title": "CatalogService listCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated with the project.", + "canonical": true, + "file": "catalog_service.list_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListCatalogsResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_UpdateCatalog_async", + "title": "CatalogService updateCatalog Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s.", + "canonical": true, + "file": "catalog_service.update_catalog.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": ".google.cloud.retail.v2beta.Catalog" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.Catalog", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_SetDefaultBranch_async", + "title": "CatalogService setDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", + "canonical": true, + "file": "catalog_service.set_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "branch_id", + "type": "TYPE_STRING" + }, + { + "name": "note", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_GetDefaultBranch_async", + "title": "CatalogService getDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] method under a specified parent catalog.", + "canonical": true, + "file": "catalog_service.get_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.GetDefaultBranchResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_GetCompletionConfig_async", + "title": "CatalogService getCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig].", + "canonical": true, + "file": "catalog_service.get_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async", + "title": "CatalogService updateCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s.", + "canonical": true, + "file": "catalog_service.update_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", + "async": true, + "parameters": [ + { + "name": "completion_config", + "type": ".google.cloud.retail.v2beta.CompletionConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_GetAttributesConfig_async", + "title": "CatalogService getAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig].", + "canonical": true, + "file": "catalog_service.get_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async", + "title": "CatalogService updateAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", + "canonical": true, + "file": "catalog_service.update_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": ".google.cloud.retail.v2beta.AttributesConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_AddCatalogAttribute_async", + "title": "CatalogService addCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "catalog_service.add_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2beta.CatalogAttribute" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async", + "title": "CatalogService removeCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.remove_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "key", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async", + "title": "CatalogService replaceCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.replace_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2beta.CatalogAttribute" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CompletionService_CompleteQuery_async", + "title": "CatalogService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 109, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "language_codes", + "type": "TYPE_STRING[]" + }, + { + "name": "device_type", + "type": "TYPE_STRING" + }, + { + "name": "dataset", + "type": "TYPE_STRING" + }, + { + "name": "max_suggestions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.retail.v2beta.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2beta.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CompletionService_ImportCompletionData_async", + "title": "CatalogService importCompletionData Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.import_completion_data.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2beta.CompletionDataInputConfig" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" + }, + "method": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2beta.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_CreateControl_async", + "title": "CatalogService createControl Sample", + "origin": "API_DEFINITION", + "description": " Creates a Control. If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "control_service.create_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "control", + "type": ".google.cloud.retail.v2beta.Control" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_DeleteControl_async", + "title": "CatalogService deleteControl Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Control. If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.delete_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_UpdateControl_async", + "title": "CatalogService updateControl Sample", + "origin": "API_DEFINITION", + "description": " Updates a Control. [Control][google.cloud.retail.v2beta.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", + "async": true, + "parameters": [ + { + "name": "control", + "type": ".google.cloud.retail.v2beta.Control" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_GetControl_async", + "title": "CatalogService getControl Sample", + "origin": "API_DEFINITION", + "description": " Gets a Control.", + "canonical": true, + "file": "control_service.get_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_ListControls_async", + "title": "CatalogService listControls Sample", + "origin": "API_DEFINITION", + "description": " Lists all Controls linked to this catalog.", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListControlsResponse", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_PredictionService_Predict_async", + "title": "CatalogService predict Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation prediction.", + "canonical": true, + "file": "prediction_service.predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 153, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2beta.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.retail.v2beta.PredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.retail.v2beta.PredictionServiceClient" + }, + "method": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.retail.v2beta.PredictionService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_CreateProduct_async", + "title": "CatalogService createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.retail.v2beta.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_GetProduct_async", + "title": "CatalogService getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_ListProducts_async", + "title": "CatalogService listProducts Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Product][google.cloud.retail.v2beta.Product]s.", + "canonical": true, + "file": "product_service.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 124, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "read_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListProductsResponse", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_UpdateProduct_async", + "title": "CatalogService updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.retail.v2beta.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2beta.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_DeleteProduct_async", + "title": "CatalogService deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_ImportProducts_async", + "title": "CatalogService importProducts Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2beta.Product]s to be successfully updated.", + "canonical": true, + "file": "product_service.import_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2beta.ProductInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_SetInventory_async", + "title": "CatalogService setInventory Sample", + "origin": "API_DEFINITION", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2beta.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 116, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", + "async": true, + "parameters": [ + { + "name": "inventory", + "type": ".google.cloud.retail.v2beta.Product" + }, + { + "name": "set_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "set_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async", + "title": "CatalogService addFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async", + "title": "CatalogService removeFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 103, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_AddLocalInventories_async", + "title": "CatalogService addLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Updates local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 92, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "local_inventories", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "add_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_RemoveLocalInventories_async", + "title": "CatalogService removeLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Remove local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_SearchService_Search_async", + "title": "CatalogService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 253, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2beta.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.retail.v2beta.UserInfo" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "canonical_filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "dynamic_facet_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec" + }, + { + "name": "boost_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.BoostSpec" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec" + }, + { + "name": "variant_rollup_keys", + "type": "TYPE_STRING[]" + }, + { + "name": "page_categories", + "type": "TYPE_STRING[]" + }, + { + "name": "search_mode", + "type": ".google.cloud.retail.v2beta.SearchRequest.SearchMode" + }, + { + "name": "personalization_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec" + } + ], + "resultType": ".google.cloud.retail.v2beta.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.retail.v2beta.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2beta.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.retail.v2beta.SearchService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_CreateServingConfig_async", + "title": "CatalogService createServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise a FAILED_PRECONDITION error is returned.", + "canonical": true, + "file": "serving_config_service.create_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "serving_config", + "type": ".google.cloud.retail.v2beta.ServingConfig" + }, + { + "name": "serving_config_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async", + "title": "CatalogService deleteServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.delete_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async", + "title": "CatalogService updateServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates a ServingConfig.", + "canonical": true, + "file": "serving_config_service.update_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": ".google.cloud.retail.v2beta.ServingConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_GetServingConfig_async", + "title": "CatalogService getServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.get_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_ListServingConfigs_async", + "title": "CatalogService listServingConfigs Sample", + "origin": "API_DEFINITION", + "description": " Lists all ServingConfigs linked to this catalog.", + "canonical": true, + "file": "serving_config_service.list_serving_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListServingConfigsResponse", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_AddControl_async", + "title": "CatalogService addControl Sample", + "origin": "API_DEFINITION", + "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", + "canonical": true, + "file": "serving_config_service.add_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_RemoveControl_async", + "title": "CatalogService removeControl Sample", + "origin": "API_DEFINITION", + "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", + "canonical": true, + "file": "serving_config_service.remove_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_WriteUserEvent_async", + "title": "CatalogService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2beta.UserEvent" + } + ], + "resultType": ".google.cloud.retail.v2beta.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_CollectUserEvent_async", + "title": "CatalogService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_PurgeUserEvents_async", + "title": "CatalogService purgeUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", + "canonical": true, + "file": "user_event_service.purge_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 83, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_ImportUserEvents_async", + "title": "CatalogService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2beta.UserEventInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_RejoinUserEvents_async", + "title": "CatalogService rejoinUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", + "canonical": true, + "file": "user_event_service.rejoin_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event_rejoin_scope", + "type": ".google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js new file mode 100644 index 00000000..933ec59d --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2beta_generated_UserEventService_CollectUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + */ + // const userEvent = 'abc123' + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + */ + // const uri = 'abc123' + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + */ + // const ets = 1234 + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END retail_v2beta_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js new file mode 100644 index 00000000..842e14dd --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2beta_generated_UserEventService_ImportUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. `projects/1234/locations/global/catalogs/default_catalog` + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorsConfig = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END retail_v2beta_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js new file mode 100644 index 00000000..059d6944 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js @@ -0,0 +1,91 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2beta_generated_UserEventService_PurgeUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * * `eventType`: Double quoted + * UserEvent.event_type google.cloud.retail.v2beta.UserEvent.event_type + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * Examples: + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * The filtering fields are assumed to have an implicit AND. + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + */ + // const force = true + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callPurgeUserEvents() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeUserEvents(); + // [END retail_v2beta_generated_UserEventService_PurgeUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000..aebf64dc --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_UserEventService_RejoinUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + */ + // const userEventRejoinScope = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callRejoinUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await retailClient.rejoinUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRejoinUserEvents(); + // [END retail_v2beta_generated_UserEventService_RejoinUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js new file mode 100644 index 00000000..da53a142 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2beta_generated_UserEventService_WriteUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END retail_v2beta_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/src/index.ts b/owl-bot-staging/v2beta/src/index.ts new file mode 100644 index 00000000..4f42efab --- /dev/null +++ b/owl-bot-staging/v2beta/src/index.ts @@ -0,0 +1,39 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 v2beta from './v2beta'; +const CatalogServiceClient = v2beta.CatalogServiceClient; +type CatalogServiceClient = v2beta.CatalogServiceClient; +const CompletionServiceClient = v2beta.CompletionServiceClient; +type CompletionServiceClient = v2beta.CompletionServiceClient; +const ControlServiceClient = v2beta.ControlServiceClient; +type ControlServiceClient = v2beta.ControlServiceClient; +const PredictionServiceClient = v2beta.PredictionServiceClient; +type PredictionServiceClient = v2beta.PredictionServiceClient; +const ProductServiceClient = v2beta.ProductServiceClient; +type ProductServiceClient = v2beta.ProductServiceClient; +const SearchServiceClient = v2beta.SearchServiceClient; +type SearchServiceClient = v2beta.SearchServiceClient; +const ServingConfigServiceClient = v2beta.ServingConfigServiceClient; +type ServingConfigServiceClient = v2beta.ServingConfigServiceClient; +const UserEventServiceClient = v2beta.UserEventServiceClient; +type UserEventServiceClient = v2beta.UserEventServiceClient; +export {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +export default {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts new file mode 100644 index 00000000..7c74bd3f --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts @@ -0,0 +1,1865 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/catalog_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './catalog_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for managing catalog configuration. + * @class + * @memberof v2beta + */ +export class CatalogServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + catalogServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CatalogServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CatalogServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listCatalogs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.CatalogService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.catalogServiceStub) { + return this.catalogServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.CatalogService. + this.catalogServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.CatalogService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.CatalogService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const catalogServiceStubMethods = + ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch', 'getCompletionConfig', 'updateCompletionConfig', 'getAttributesConfig', 'updateAttributesConfig', 'addCatalogAttribute', 'removeCatalogAttribute', 'replaceCatalogAttribute']; + for (const methodName of catalogServiceStubMethods) { + const callPromise = this.catalogServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.catalogServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Updates the {@link google.cloud.retail.v2beta.Catalog|Catalog}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Catalog} request.catalog + * Required. The {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.Catalog|Catalog}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Catalog|Catalog} to update does not + * exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2beta.Catalog}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.update_catalog.js + * region_tag:retail_v2beta_generated_CatalogService_UpdateCatalog_async + */ + updateCatalog( + request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|undefined, {}|undefined + ]>; + updateCatalog( + request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog.name': request.catalog!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCatalog(request, options, callback); + } +/** + * Set a specified branch id as default branch. API methods such as + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search}, + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct}, + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as + * default, setting + * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` + * as {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} + * to route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.branchId + * The final component of the resource name of a branch. + * + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * + * If there are no sufficient active products in the targeted branch and + * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.force|force} is not + * set, a FAILED_PRECONDITION error is returned. + * @param {string} request.note + * Some note on this request, this can be retrieved by + * {@link google.cloud.retail.v2beta.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} + * before next valid default branch set occurs. + * + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {boolean} request.force + * If set to true, it permits switching to a branch with + * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id|branch_id} + * even if it has no sufficient active products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.set_default_branch.js + * region_tag:retail_v2beta_generated_CatalogService_SetDefaultBranch_async + */ + setDefaultBranch( + request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|undefined, {}|undefined + ]>; + setDefaultBranch( + request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultBranch(request, options, callback); + } +/** + * Get which branch is currently default branch set by + * {@link google.cloud.retail.v2beta.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} + * method under a specified parent catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2beta.GetDefaultBranchResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.get_default_branch.js + * region_tag:retail_v2beta_generated_CatalogService_GetDefaultBranch_async + */ + getDefaultBranch( + request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|undefined, {}|undefined + ]>; + getDefaultBranch( + request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.get_completion_config.js + * region_tag:retail_v2beta_generated_CatalogService_GetCompletionConfig_async + */ + getCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|undefined, {}|undefined + ]>; + getCompletionConfig( + request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getCompletionConfig(request, options, callback); + } +/** + * Updates the + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.CompletionConfig} request.completionConfig + * Required. The + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to + * update does not exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. + * The following are the only supported fields: + * + * * {@link google.cloud.retail.v2beta.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link google.cloud.retail.v2beta.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link google.cloud.retail.v2beta.CompletionConfig.auto_learning|CompletionConfig.auto_learning} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.update_completion_config.js + * region_tag:retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async + */ + updateCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|undefined, {}|undefined + ]>; + updateCompletionConfig( + request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'completion_config.name': request.completionConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCompletionConfig(request, options, callback); + } +/** + * Gets an {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.get_attributes_config.js + * region_tag:retail_v2beta_generated_CatalogService_GetAttributesConfig_async + */ + getAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|undefined, {}|undefined + ]>; + getAttributesConfig( + request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getAttributesConfig(request, options, callback); + } +/** + * Updates the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * The catalog attributes in the request will be updated in the catalog, or + * inserted if they do not exist. Existing catalog attributes not included in + * the request will remain unchanged. Attributes that are assigned to + * products, but do not exist at the catalog level, are always included in the + * response. The product attribute is assigned default values for missing + * catalog attribute fields, e.g., searchable and dynamic facetable options. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.AttributesConfig} request.attributesConfig + * Required. The + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. + * The following is the only supported field: + * + * * {@link google.cloud.retail.v2beta.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.update_attributes_config.js + * region_tag:retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async + */ + updateAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|undefined, {}|undefined + ]>; + updateAttributesConfig( + request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config.name': request.attributesConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateAttributesConfig(request, options, callback); + } +/** + * Adds the specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to + * add already exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute + * Required. The + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to add. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.add_catalog_attribute.js + * region_tag:retail_v2beta_generated_CatalogService_AddCatalogAttribute_async + */ + addCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|undefined, {}|undefined + ]>; + addCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.addCatalogAttribute(request, options, callback); + } +/** + * Removes the specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} from the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to + * remove does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {string} request.key + * Required. The attribute name key of the + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to remove. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.remove_catalog_attribute.js + * region_tag:retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async + */ + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|undefined, {}|undefined + ]>; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute(request, options, callback); + } +/** + * Replaces the specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} in the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} by updating + * the catalog attribute with the same + * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to + * replace does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute + * Required. The updated + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to update. + * The following are NOT supported: + * + * * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.replace_catalog_attribute.js + * region_tag:retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async + */ + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|undefined, {}|undefined + ]>; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.replaceCatalogAttribute(request, options, callback); + } + + /** + * Lists all the {@link google.cloud.retail.v2beta.Catalog|Catalog}s associated + * with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2beta.Catalog}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogs( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICatalog[], + protos.google.cloud.retail.v2beta.IListCatalogsRequest|null, + protos.google.cloud.retail.v2beta.IListCatalogsResponse + ]>; + listCatalogs( + request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2beta.ICatalog>): void; + listCatalogs( + request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2beta.ICatalog>): void; + listCatalogs( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2beta.ICatalog>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2beta.ICatalog>): + Promise<[ + protos.google.cloud.retail.v2beta.ICatalog[], + protos.google.cloud.retail.v2beta.IListCatalogsRequest|null, + protos.google.cloud.retail.v2beta.IListCatalogsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listCatalogs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2beta.Catalog} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogsStream( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.createStream( + this.innerApiCalls.listCatalogs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCatalogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Catalog]{@link google.cloud.retail.v2beta.Catalog}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.list_catalogs.js + * region_tag:retail_v2beta_generated_CatalogService_ListCatalogs_async + */ + listCatalogsAsync( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.asyncIterate( + this.innerApiCalls['listCatalogs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.catalogServiceStub && !this._terminated) { + return this.catalogServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json new file mode 100644 index 00000000..cd2aebd1 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json @@ -0,0 +1,90 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.CatalogService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListCatalogs": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCatalog": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "SetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "AddCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "RemoveCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ReplaceCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts new file mode 100644 index 00000000..871a336d --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts @@ -0,0 +1,936 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Auto-completion service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2beta + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importCompletionDataResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportCompletionDataResponse') as gax.protobuf.Type; + const importCompletionDataMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importCompletionData: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importCompletionDataResponse.decode.bind(importCompletionDataResponse), + importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.CompletionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.CompletionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.CompletionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const completionServiceStubMethods = + ['completeQuery', 'importCompletionData']; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Required. Catalog for which the completion is performed. + * + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string} request.visitorId + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {string[]} request.languageCodes + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see [Tags for + * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + * @param {string} request.deviceType + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * + * Supported formats: + * + * * `UNKNOWN_DEVICE_TYPE` + * + * * `DESKTOP` + * + * * `MOBILE` + * + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + * @param {string} request.dataset + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * {@link google.cloud.retail.v2beta.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * + * Current supported values: + * + * * user-data + * + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + * @param {number} request.maxSuggestions + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. + * + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2beta.CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/completion_service.complete_query.js + * region_tag:retail_v2beta_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|undefined, {}|undefined + ]>; + completeQuery( + request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + +/** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog which the suggestions dataset belongs to. + * + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2beta.CompletionDataInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/completion_service.import_completion_data.js + * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async + */ + importCompletionData( + request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importCompletionData( + request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importCompletionData(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importCompletionData()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/completion_service.import_completion_data.js + * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async + */ + async checkImportCompletionDataProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json new file mode 100644 index 00000000..1865fe66 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json @@ -0,0 +1,45 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.CompletionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ImportCompletionData": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts new file mode 100644 index 00000000..297b302a --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts @@ -0,0 +1,1195 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/control_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './control_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for modifying Control. + * @class + * @memberof v2beta + */ +export class ControlServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + controlServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ControlServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ControlServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listControls: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'controls') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.ControlService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.controlServiceStub) { + return this.controlServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ControlService. + this.controlServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ControlService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ControlService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const controlServiceStubMethods = + ['createControl', 'deleteControl', 'updateControl', 'getControl', 'listControls']; + for (const methodName of controlServiceStubMethods) { + const callPromise = this.controlServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.controlServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a Control. + * + * If the {@link google.cloud.retail.v2beta.Control|Control} to create already + * exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent catalog. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {google.cloud.retail.v2beta.Control} request.control + * Required. The Control to create. + * @param {string} request.controlId + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.create_control.js + * region_tag:retail_v2beta_generated_ControlService_CreateControl_async + */ + createControl( + request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|undefined, {}|undefined + ]>; + createControl( + request: protos.google.cloud.retail.v2beta.ICreateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request: protos.google.cloud.retail.v2beta.ICreateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createControl(request, options, callback); + } +/** + * Deletes a Control. + * + * If the {@link google.cloud.retail.v2beta.Control|Control} to delete does not + * exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.delete_control.js + * region_tag:retail_v2beta_generated_ControlService_DeleteControl_async + */ + deleteControl( + request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|undefined, {}|undefined + ]>; + deleteControl( + request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteControl(request, options, callback); + } +/** + * Updates a Control. + * + * {@link google.cloud.retail.v2beta.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link google.cloud.retail.v2beta.Control|Control} to delete does not exist, a + * NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Control} request.control + * Required. The Control to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.Control|Control} to update. The following are + * NOT supported: + * + * * {@link google.cloud.retail.v2beta.Control.name|Control.name} + * + * If not set or empty, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.update_control.js + * region_tag:retail_v2beta_generated_ControlService_UpdateControl_async + */ + updateControl( + request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|undefined, {}|undefined + ]>; + updateControl( + request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'control.name': request.control!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateControl(request, options, callback); + } +/** + * Gets a Control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.get_control.js + * region_tag:retail_v2beta_generated_ControlService_GetControl_async + */ + getControl( + request?: protos.google.cloud.retail.v2beta.IGetControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|undefined, {}|undefined + ]>; + getControl( + request: protos.google.cloud.retail.v2beta.IGetControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request: protos.google.cloud.retail.v2beta.IGetControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request?: protos.google.cloud.retail.v2beta.IGetControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Control]{@link google.cloud.retail.v2beta.Control}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControls( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IControl[], + protos.google.cloud.retail.v2beta.IListControlsRequest|null, + protos.google.cloud.retail.v2beta.IListControlsResponse + ]>; + listControls( + request: protos.google.cloud.retail.v2beta.IListControlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IControl>): void; + listControls( + request: protos.google.cloud.retail.v2beta.IListControlsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IControl>): void; + listControls( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IControl>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IControl>): + Promise<[ + protos.google.cloud.retail.v2beta.IControl[], + protos.google.cloud.retail.v2beta.IListControlsRequest|null, + protos.google.cloud.retail.v2beta.IListControlsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listControls(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Control]{@link google.cloud.retail.v2beta.Control} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControlsStream( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.createStream( + this.innerApiCalls.listControls as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listControls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Control]{@link google.cloud.retail.v2beta.Control}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.list_controls.js + * region_tag:retail_v2beta_generated_ControlService_ListControls_async + */ + listControlsAsync( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.asyncIterate( + this.innerApiCalls['listControls'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.controlServiceStub && !this._terminated) { + return this.controlServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json new file mode 100644 index 00000000..b7572aeb --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ControlService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListControls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json b/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json new file mode 100644 index 00000000..f9c6514c --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json @@ -0,0 +1,571 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.retail.v2beta", + "libraryPackage": "@google-cloud/retail", + "services": { + "CatalogService": { + "clients": { + "grpc": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + } + } + }, + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + } + } + }, + "ControlService": { + "clients": { + "grpc": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "ProductService": { + "clients": { + "grpc": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "ServingConfigService": { + "clients": { + "grpc": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/index.ts b/owl-bot-staging/v2beta/src/v2beta/index.ts new file mode 100644 index 00000000..a7e4f6ba --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/index.ts @@ -0,0 +1,26 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CatalogServiceClient} from './catalog_service_client'; +export {CompletionServiceClient} from './completion_service_client'; +export {ControlServiceClient} from './control_service_client'; +export {PredictionServiceClient} from './prediction_service_client'; +export {ProductServiceClient} from './product_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {ServingConfigServiceClient} from './serving_config_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts new file mode 100644 index 00000000..7f5f710e --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts @@ -0,0 +1,837 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/prediction_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './prediction_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for making recommendation prediction. + * @class + * @memberof v2beta + */ +export class PredictionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + predictionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PredictionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PredictionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.PredictionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.predictionServiceStub) { + return this.predictionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.PredictionService. + this.predictionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.PredictionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.PredictionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const predictionServiceStubMethods = + ['predict']; + for (const methodName of predictionServiceStubMethods) { + const callPromise = this.predictionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.predictionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Makes a recommendation prediction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see [Managing + * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * @param {number} request.pageSize + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * @param {string} request.pageToken + * The previous PredictResponse.next_page_token. + * @param {string} request.filter + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * + * Examples: + * + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * @param {boolean} request.validateOnly + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the predictions. + * + * Allowed values: + * + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2beta.PredictResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/prediction_service.predict.js + * region_tag:retail_v2beta_generated_PredictionService_Predict_async + */ + predict( + request?: protos.google.cloud.retail.v2beta.IPredictRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|undefined, {}|undefined + ]>; + predict( + request: protos.google.cloud.retail.v2beta.IPredictRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request: protos.google.cloud.retail.v2beta.IPredictRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request?: protos.google.cloud.retail.v2beta.IPredictRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.predictionServiceStub && !this._terminated) { + return this.predictionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json new file mode 100644 index 00000000..ab64c45e --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.PredictionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts new file mode 100644 index 00000000..284f15d5 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts @@ -0,0 +1,2455 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/product_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.retail.v2beta.Product|Product} + * information of the customer's website. + * @class + * @memberof v2beta + */ +export class ProductServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProductServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportProductsResponse') as gax.protobuf.Type; + const importProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; + const setInventoryResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.SetInventoryResponse') as gax.protobuf.Type; + const setInventoryMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.SetInventoryMetadata') as gax.protobuf.Type; + const addFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse') as gax.protobuf.Type; + const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; + const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; + const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; + const addLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddLocalInventoriesResponse') as gax.protobuf.Type; + const addLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddLocalInventoriesMetadata') as gax.protobuf.Type; + const removeLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse') as gax.protobuf.Type; + const removeLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductsResponse.decode.bind(importProductsResponse), + importProductsMetadata.decode.bind(importProductsMetadata)), + setInventory: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInventoryResponse.decode.bind(setInventoryResponse), + setInventoryMetadata.decode.bind(setInventoryMetadata)), + addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), + addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), + removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), + removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), + addLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), + addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), + removeLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), + removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.ProductService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.productServiceStub) { + return this.productServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ProductService. + this.productServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ProductService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ProductService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const productServiceStubMethods = + ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; + for (const methodName of productServiceStubMethods) { + const callPromise = this.productServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.productServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + * @param {google.cloud.retail.v2beta.Product} request.product + * Required. The {@link google.cloud.retail.v2beta.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the + * {@link google.cloud.retail.v2beta.Product|Product}, which will become the final + * component of the {@link google.cloud.retail.v2beta.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * This field must be unique among all + * {@link google.cloud.retail.v2beta.Product|Product}s with the same + * {@link google.cloud.retail.v2beta.CreateProductRequest.parent|parent}. + * Otherwise, an ALREADY_EXISTS error is returned. + * + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.create_product.js + * region_tag:retail_v2beta_generated_ProductService_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.retail.v2beta.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.retail.v2beta.ICreateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link google.cloud.retail.v2beta.Product|Product} does not + * exist, a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.get_product.js + * region_tag:retail_v2beta_generated_ProductService_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.retail.v2beta.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.retail.v2beta.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.retail.v2beta.IGetProductRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.retail.v2beta.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Updates a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Product} request.product + * Required. The product to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not + * exist and + * {@link google.cloud.retail.v2beta.UpdateProductRequest.allow_missing|allow_missing} + * is not set, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.Product|Product} to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, a new {@link google.cloud.retail.v2beta.Product|Product} will be + * created. In this situation, `update_mask` is ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.update_product.js + * region_tag:retail_v2beta_generated_ProductService_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Deletes a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to delete does not + * exist, a NOT_FOUND error is returned. + * + * The {@link google.cloud.retail.v2beta.Product|Product} to delete can neither be + * a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} member nor a + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} with more than one + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link google.cloud.retail.v2beta.Product|Product} will be deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.delete_product.js + * region_tag:retail_v2beta_generated_ProductService_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } + +/** + * Bulk import of multiple {@link google.cloud.retail.v2beta.Product|Product}s. + * + * Request processing may be synchronous. No partial updating is supported. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * {@link google.cloud.retail.v2beta.Product|Product}s to be successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + * @param {string} request.requestId + * Deprecated. This field has no effect. + * @param {google.cloud.retail.v2beta.ProductInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + * @param {google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * {@link google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * + * Only supported when + * {@link google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} + * is set to `FULL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.import_products.js + * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async + */ + importProducts( + request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProducts( + request: protos.google.cloud.retail.v2beta.IImportProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request: protos.google.cloud.retail.v2beta.IImportProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.import_products.js + * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async + */ + async checkImportProductsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates inventory information for a + * {@link google.cloud.retail.v2beta.Product|Product} while respecting the last + * update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, updates are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct}, + * the specified inventory field value(s) will overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update time for the specified inventory fields will be overwritten to the + * time of the + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} or + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2beta.CreateProductRequest.product|CreateProductRequest.product}, + * then any pre-existing inventory information for this product will be used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information will be preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2beta.ProductService.SetInventory|SetInventory}, + * {@link google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Product} request.inventory + * Required. The inventory information to update. The allowable fields to + * update are: + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.Product|Product} named in + * {@link google.cloud.retail.v2beta.Product.name|Product.name}, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. + * + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} + * + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link |SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} + * + * The last update time is recorded for the following inventory fields: + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, {@link |UpdateProduct} should be invoked instead. + * @param {google.protobuf.FieldMask} request.setMask + * Indicates which inventory fields in the provided + * {@link google.cloud.retail.v2beta.Product|Product} to update. + * + * At least one field must be provided. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.setTime + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} with + * name {@link google.cloud.retail.v2beta.Product.name|Product.name} is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the {@link google.cloud.retail.v2beta.Product|Product} is created. If set + * to false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.set_inventory.js + * region_tag:retail_v2beta_generated_ProductService_SetInventory_async + */ + setInventory( + request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInventory( + request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'inventory.name': request.inventory!.name || '', + }); + this.initialize(); + return this.innerApiCalls.setInventory(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInventory()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.set_inventory.js + * region_tag:retail_v2beta_generated_ProductService_SetInventory_async + */ + async checkSetInventoryProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally adds place IDs to + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}. + * Duplicate IDs will be automatically ignored. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * If the total number of place IDs exceeds 2000 for this + * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type} after + * adding, then the update will be rejected. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async + */ + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async + */ + async checkAddFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally removes place IDs from a + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async + */ + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async + */ + async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates local inventory information for a + * {@link google.cloud.retail.v2beta.Product|Product} at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {number[]} request.localInventories + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + * @param {google.protobuf.FieldMask} request.addMask + * Indicates which inventory fields in the provided list of + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory} to update. The + * field is updated to the provided value. + * + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async + */ + addLocalInventories( + request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addLocalInventories( + request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async + */ + async checkAddLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Remove local inventory information for a + * {@link google.cloud.retail.v2beta.Product|Product} at a list of places at a + * removal timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {string[]} request.placeIds + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async + */ + removeLocalInventories( + request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeLocalInventories( + request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async + */ + async checkRemoveLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.retail.v2beta.Product|Product}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} or + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.retail.v2beta.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct[], + protos.google.cloud.retail.v2beta.IListProductsRequest|null, + protos.google.cloud.retail.v2beta.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.retail.v2beta.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IProduct>): void; + listProducts( + request: protos.google.cloud.retail.v2beta.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IProduct>): void; + listProducts( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IProduct>): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct[], + protos.google.cloud.retail.v2beta.IListProductsRequest|null, + protos.google.cloud.retail.v2beta.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} or + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2beta.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} or + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.retail.v2beta.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.list_products.js + * region_tag:retail_v2beta_generated_ProductService_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.productServiceStub && !this._terminated) { + return this.productServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json new file mode 100644 index 00000000..459b579d --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json @@ -0,0 +1,99 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ProductService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "GetProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ListProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "UpdateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "DeleteProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportProducts": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "SetInventory": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts new file mode 100644 index 00000000..d3d87c33 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts @@ -0,0 +1,1480 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2beta + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + search: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.SearchService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.SearchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.SearchService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const searchServiceStubMethods = + ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2beta.ISearchRequest|null, + protos.google.cloud.retail.v2beta.ISearchResponse + ]>; + search( + request: protos.google.cloud.retail.v2beta.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): void; + search( + request: protos.google.cloud.retail.v2beta.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): void; + search( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): + Promise<[ + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2beta.ISearchRequest|null, + protos.google.cloud.retail.v2beta.ISearchResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `search`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/search_service.search.js + * region_tag:retail_v2beta_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json new file mode 100644 index 00000000..82de0f81 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.SearchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts new file mode 100644 index 00000000..9f807827 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts @@ -0,0 +1,1333 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/serving_config_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './serving_config_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for modifying ServingConfig. + * @class + * @memberof v2beta + */ +export class ServingConfigServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + servingConfigServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServingConfigServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServingConfigServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listServingConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'servingConfigs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.ServingConfigService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.servingConfigServiceStub) { + return this.servingConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ServingConfigService. + this.servingConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ServingConfigService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ServingConfigService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const servingConfigServiceStubMethods = + ['createServingConfig', 'deleteServingConfig', 'updateServingConfig', 'getServingConfig', 'listServingConfigs', 'addControl', 'removeControl']; + for (const methodName of servingConfigServiceStubMethods) { + const callPromise = this.servingConfigServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.servingConfigServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a ServingConfig. + * + * A maximum of 100 {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig}s + * are allowed in a {@link google.cloud.retail.v2beta.Catalog|Catalog}, otherwise + * a FAILED_PRECONDITION error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig + * Required. The ServingConfig to create. + * @param {string} request.servingConfigId + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.create_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_CreateServingConfig_async + */ + createServingConfig( + request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|undefined, {}|undefined + ]>; + createServingConfig( + request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createServingConfig(request, options, callback); + } +/** + * Deletes a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.delete_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async + */ + deleteServingConfig( + request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|undefined, {}|undefined + ]>; + deleteServingConfig( + request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteServingConfig(request, options, callback); + } +/** + * Updates a ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig + * Required. The ServingConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2beta.ServingConfig.name|ServingConfig.name} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.update_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async + */ + updateServingConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|undefined, {}|undefined + ]>; + updateServingConfig( + request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config.name': request.servingConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateServingConfig(request, options, callback); + } +/** + * Gets a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.get_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_GetServingConfig_async + */ + getServingConfig( + request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|undefined, {}|undefined + ]>; + getServingConfig( + request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getServingConfig(request, options, callback); + } +/** + * Enables a Control on the specified ServingConfig. + * The control is added in the last position of the list of controls + * it belongs to (e.g. if it's a facet spec control it will be applied + * in the last position of servingConfig.facetSpecIds) + * Returns a ALREADY_EXISTS error if the control has already been applied. + * Returns a FAILED_PRECONDITION error if the addition could exceed maximum + * number of control allowed for that type of control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.add_control.js + * region_tag:retail_v2beta_generated_ServingConfigService_AddControl_async + */ + addControl( + request?: protos.google.cloud.retail.v2beta.IAddControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|undefined, {}|undefined + ]>; + addControl( + request: protos.google.cloud.retail.v2beta.IAddControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request: protos.google.cloud.retail.v2beta.IAddControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request?: protos.google.cloud.retail.v2beta.IAddControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config': request.servingConfig || '', + }); + this.initialize(); + return this.innerApiCalls.addControl(request, options, callback); + } +/** + * Disables a Control on the specified ServingConfig. + * The control is removed from the ServingConfig. + * Returns a NOT_FOUND error if the Control is not enabled for the + * ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.remove_control.js + * region_tag:retail_v2beta_generated_ServingConfigService_RemoveControl_async + */ + removeControl( + request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|undefined, {}|undefined + ]>; + removeControl( + request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config': request.servingConfig || '', + }); + this.initialize(); + return this.innerApiCalls.removeControl(request, options, callback); + } + + /** + * Lists all ServingConfigs linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigs( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig[], + protos.google.cloud.retail.v2beta.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse + ]>; + listServingConfigs( + request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IServingConfig>): void; + listServingConfigs( + request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IServingConfig>): void; + listServingConfigs( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IServingConfig>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IServingConfig>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig[], + protos.google.cloud.retail.v2beta.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listServingConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigsStream( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.createStream( + this.innerApiCalls.listServingConfigs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServingConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.list_serving_configs.js + * region_tag:retail_v2beta_generated_ServingConfigService_ListServingConfigs_async + */ + listServingConfigsAsync( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.asyncIterate( + this.innerApiCalls['listServingConfigs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.servingConfigServiceStub && !this._terminated) { + return this.servingConfigServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json new file mode 100644 index 00000000..2d17b527 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ServingConfigService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServingConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts new file mode 100644 index 00000000..86906d7b --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts @@ -0,0 +1,1201 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on the customer website. + * @class + * @memberof v2beta + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const purgeUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.PurgeUserEventsResponse') as gax.protobuf.Type; + const purgeUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.PurgeMetadata') as gax.protobuf.Type; + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportUserEventsResponse') as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; + const rejoinUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RejoinUserEventsResponse') as gax.protobuf.Type; + const rejoinUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RejoinUserEventsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), + purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata)), + rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), + rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.UserEventService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.UserEventService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.UserEventService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const userEventServiceStubMethods = + ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2beta.UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.write_user_event.js + * region_tag:retail_v2beta_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|undefined, {}|undefined + ]>; + writeUserEvent( + request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } +/** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.collect_user_event.js + * region_tag:retail_v2beta_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|undefined, {}|undefined + ]>; + collectUserEvent( + request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + +/** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + * @param {string} request.filter + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * + * * `eventType`: Double quoted + * {@link google.cloud.retail.v2beta.UserEvent.event_type|UserEvent.event_type} + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * + * Examples: + * + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * + * The filtering fields are assumed to have an implicit AND. + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async + */ + purgeUserEvents( + request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeUserEvents( + request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.purgeUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async + */ + async checkPurgeUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. `projects/1234/locations/global/catalogs/default_catalog` + * @param {google.cloud.retail.v2beta.UserEventInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.import_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importUserEvents( + request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.import_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a user event rejoin operation with latest product catalog. Events + * will not be annotated with detailed product information if product is + * missing from the catalog at the time the user event is ingested, and these + * events are stored as unjoined events with a limited usage on training and + * serving. This method can be used to start a join operation on specified + * events with latest version of product catalog. It can also be used to + * correct events joined with the wrong product catalog. A rejoin operation + * can take hours or days to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async + */ + rejoinUserEvents( + request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rejoinUserEvents( + request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.rejoinUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rejoinUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async + */ + async checkRejoinUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json new file mode 100644 index 00000000..f5bd2bae --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.UserEventService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "CollectUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "PurgeUserEvents": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportUserEvents": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "RejoinUserEvents": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..57b7c7be --- /dev/null +++ b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js @@ -0,0 +1,34 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const retail = require('@google-cloud/retail'); + +function main() { + const catalogServiceClient = new retail.CatalogServiceClient(); + const completionServiceClient = new retail.CompletionServiceClient(); + const controlServiceClient = new retail.ControlServiceClient(); + const predictionServiceClient = new retail.PredictionServiceClient(); + const productServiceClient = new retail.ProductServiceClient(); + const searchServiceClient = new retail.SearchServiceClient(); + const servingConfigServiceClient = new retail.ServingConfigServiceClient(); + const userEventServiceClient = new retail.UserEventServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..25eaae42 --- /dev/null +++ b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts @@ -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. ** + +import {CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient} from '@google-cloud/retail'; + +// check that the client class type name can be used +function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { + client.close(); +} +function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { + client.close(); +} +function doStuffWithControlServiceClient(client: ControlServiceClient) { + client.close(); +} +function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { + client.close(); +} +function doStuffWithProductServiceClient(client: ProductServiceClient) { + client.close(); +} +function doStuffWithSearchServiceClient(client: SearchServiceClient) { + client.close(); +} +function doStuffWithServingConfigServiceClient(client: ServingConfigServiceClient) { + client.close(); +} +function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const catalogServiceClient = new CatalogServiceClient(); + doStuffWithCatalogServiceClient(catalogServiceClient); + // check that the client instance can be created + const completionServiceClient = new CompletionServiceClient(); + doStuffWithCompletionServiceClient(completionServiceClient); + // check that the client instance can be created + const controlServiceClient = new ControlServiceClient(); + doStuffWithControlServiceClient(controlServiceClient); + // check that the client instance can be created + const predictionServiceClient = new PredictionServiceClient(); + doStuffWithPredictionServiceClient(predictionServiceClient); + // check that the client instance can be created + const productServiceClient = new ProductServiceClient(); + doStuffWithProductServiceClient(productServiceClient); + // check that the client instance can be created + const searchServiceClient = new SearchServiceClient(); + doStuffWithSearchServiceClient(searchServiceClient); + // check that the client instance can be created + const servingConfigServiceClient = new ServingConfigServiceClient(); + doStuffWithServingConfigServiceClient(servingConfigServiceClient); + // check that the client instance can be created + const userEventServiceClient = new UserEventServiceClient(); + doStuffWithUserEventServiceClient(userEventServiceClient); +} + +main(); diff --git a/owl-bot-staging/v2beta/system-test/install.ts b/owl-bot-staging/v2beta/system-test/install.ts new file mode 100644 index 00000000..8ec45222 --- /dev/null +++ b/owl-bot-staging/v2beta/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/v2beta/test/gapic_catalog_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts new file mode 100644 index 00000000..c264bc2d --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts @@ -0,0 +1,1790 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as catalogserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.CatalogServiceClient', () => { + it('has servicePath', () => { + const servicePath = catalogserviceModule.v2beta.CatalogServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = catalogserviceModule.v2beta.CatalogServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = catalogserviceModule.v2beta.CatalogServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + await client.initialize(); + assert(client.catalogServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.catalogServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('updateCatalog', () => { + it('invokes updateCatalog without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); + const [response] = await client.updateCatalog(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCatalog( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICatalog|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCatalog with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCatalog(request), expectedError); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCatalog(request), expectedError); + }); + }); + + describe('setDefaultBranch', () => { + it('invokes setDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultBranch( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultBranch(request), expectedError); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultBranch(request), expectedError); + }); + }); + + describe('getDefaultBranch', () => { + it('invokes getDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.getDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDefaultBranch( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDefaultBranch(request), expectedError); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDefaultBranch(request), expectedError); + }); + }); + + describe('getCompletionConfig', () => { + it('invokes getCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); + client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCompletionConfig(request), expectedError); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCompletionConfig(request), expectedError); + }); + }); + + describe('updateCompletionConfig', () => { + it('invokes updateCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); + client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + }); + }); + + describe('getAttributesConfig', () => { + it('invokes getAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAttributesConfig(request), expectedError); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAttributesConfig(request), expectedError); + }); + }); + + describe('updateAttributesConfig', () => { + it('invokes updateAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + }); + }); + + describe('addCatalogAttribute', () => { + it('invokes addCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.addCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + }); + }); + + describe('removeCatalogAttribute', () => { + it('invokes removeCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.removeCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + }); + }); + + describe('replaceCatalogAttribute', () => { + it('invokes replaceCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.replaceCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes replaceCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.replaceCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes replaceCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes replaceCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + }); + }); + + describe('listCatalogs', () => { + it('invokes listCatalogs without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.listCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogs without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCatalogs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICatalog[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCatalogs with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCatalogs(request), expectedError); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogsStream without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCatalogsStream with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; + const iterable = client.listCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts new file mode 100644 index 00000000..26af45db --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts @@ -0,0 +1,703 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as completionserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2beta.CompletionServiceClient', () => { + it('has servicePath', () => { + const servicePath = completionserviceModule.v2beta.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = completionserviceModule.v2beta.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v2beta.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompleteQueryResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('importCompletionData', () => { + it('invokes importCompletionData without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); + const [operation] = await client.importCompletionData(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCompletionData( + request, + (err?: Error|null, + result?: LROperation|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.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importCompletionData with call error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importCompletionData(request), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData with LRO error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportCompletionDataProgress without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportCompletionDataProgress with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts new file mode 100644 index 00000000..4ba4bd3c --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts @@ -0,0 +1,1108 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as controlserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.ControlServiceClient', () => { + it('has servicePath', () => { + const servicePath = controlserviceModule.v2beta.ControlServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = controlserviceModule.v2beta.ControlServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = controlserviceModule.v2beta.ControlServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new controlserviceModule.v2beta.ControlServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + await client.initialize(); + assert(client.controlServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.controlServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createControl', () => { + it('invokes createControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); + const [response] = await client.createControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createControl(request), expectedError); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createControl(request), expectedError); + }); + }); + + describe('deleteControl', () => { + it('invokes deleteControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteControl( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteControl(request), expectedError); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteControl(request), expectedError); + }); + }); + + describe('updateControl', () => { + it('invokes updateControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); + const [response] = await client.updateControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateControl(request), expectedError); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateControl(request), expectedError); + }); + }); + + describe('getControl', () => { + it('invokes getControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); + const [response] = await client.getControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getControl(request), expectedError); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getControl(request), expectedError); + }); + }); + + describe('listControls', () => { + it('invokes listControls without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); + const [response] = await client.listControls(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listControls without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listControls( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listControls with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listControls(request), expectedError); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listControlsStream without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.descriptors.page.listControls.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Control) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listControls, request)); + assert.strictEqual( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listControlsStream with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Control) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listControls, request)); + assert.strictEqual( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listControls without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IControl[] = []; + const iterable = client.listControlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listControls with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listControlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.IControl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts new file mode 100644 index 00000000..ca636e40 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts @@ -0,0 +1,543 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as predictionserviceModule from '../src'; + +import {protobuf} 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('v2beta.PredictionServiceClient', () => { + it('has servicePath', () => { + const servicePath = predictionserviceModule.v2beta.PredictionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = predictionserviceModule.v2beta.PredictionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = predictionserviceModule.v2beta.PredictionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + await client.initialize(); + assert(client.predictionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.predictionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('predict', () => { + it('invokes predict without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCall(expectedResponse); + const [response] = await client.predict(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.predict( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IPredictResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes predict with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict with closed client', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); + request.placement = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts new file mode 100644 index 00000000..b483f593 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts @@ -0,0 +1,2046 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as productserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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('v2beta.ProductServiceClient', () => { + it('has servicePath', () => { + const servicePath = productserviceModule.v2beta.ProductServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productserviceModule.v2beta.ProductServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productserviceModule.v2beta.ProductServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productserviceModule.v2beta.ProductServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + await client.initialize(); + assert(client.productServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('importProducts', () => { + it('invokes importProducts without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProducts( + request, + (err?: Error|null, + result?: LROperation|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.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProducts with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProducts(request), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductsProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductsProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInventory', () => { + it('invokes setInventory without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInventory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInventory( + request, + (err?: Error|null, + result?: LROperation|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.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setInventory with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInventory(request), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkSetInventoryProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInventoryProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInventoryProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addFulfillmentPlaces', () => { + it('invokes addFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeFulfillmentPlaces', () => { + it('invokes removeFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addLocalInventories', () => { + it('invokes addLocalInventories without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.addLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addLocalInventories with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addLocalInventories(request), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeLocalInventories', () => { + it('invokes removeLocalInventories without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeLocalInventories with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeLocalInventories(request), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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.retail.v2beta.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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.retail.v2beta.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts new file mode 100644 index 00000000..f654dd43 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts @@ -0,0 +1,770 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.SearchServiceClient', () => { + it('has servicePath', () => { + const servicePath = searchserviceModule.v2beta.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = searchserviceModule.v2beta.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v2beta.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v2beta.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts new file mode 100644 index 00000000..f7adf822 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts @@ -0,0 +1,1302 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as servingconfigserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.ServingConfigServiceClient', () => { + it('has servicePath', () => { + const servicePath = servingconfigserviceModule.v2beta.ServingConfigServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = servingconfigserviceModule.v2beta.ServingConfigServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = servingconfigserviceModule.v2beta.ServingConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + await client.initialize(); + assert(client.servingConfigServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servingConfigServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createServingConfig', () => { + it('invokes createServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.createServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createServingConfig(request), expectedError); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createServingConfig(request), expectedError); + }); + }); + + describe('deleteServingConfig', () => { + it('invokes deleteServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServingConfig( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteServingConfig(request), expectedError); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteServingConfig(request), expectedError); + }); + }); + + describe('updateServingConfig', () => { + it('invokes updateServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateServingConfig(request), expectedError); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateServingConfig(request), expectedError); + }); + }); + + describe('getServingConfig', () => { + it('invokes getServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getServingConfig(request), expectedError); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getServingConfig(request), expectedError); + }); + }); + + describe('addControl', () => { + it('invokes addControl without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); + const [response] = await client.addControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addControl with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addControl(request), expectedError); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addControl with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); + request.servingConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addControl(request), expectedError); + }); + }); + + describe('removeControl', () => { + it('invokes removeControl without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); + const [response] = await client.removeControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeControl with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeControl(request), expectedError); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeControl with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); + request.servingConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeControl(request), expectedError); + }); + }); + + describe('listServingConfigs', () => { + it('invokes listServingConfigs without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listServingConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServingConfigs without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServingConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServingConfigs(request), expectedError); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServingConfigsStream without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + ]; + client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.ServingConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listServingConfigsStream with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.ServingConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServingConfigs without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + ]; + client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = []; + const iterable = client.listServingConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServingConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts new file mode 100644 index 00000000..dd385461 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts @@ -0,0 +1,1088 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as usereventserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2beta.UserEventServiceClient', () => { + it('has servicePath', () => { + const servicePath = usereventserviceModule.v2beta.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = usereventserviceModule.v2beta.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v2beta.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IUserEvent|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('purgeUserEvents', () => { + it('invokes purgeUserEvents without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeUserEvents with call error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeUserEvents(request), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rejoinUserEvents', () => { + it('invokes rejoinUserEvents without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.rejoinUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejoinUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes rejoinUserEvents with call error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRejoinUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRejoinUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/tsconfig.json b/owl-bot-staging/v2beta/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v2beta/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/v2beta/webpack.config.js b/owl-bot-staging/v2beta/webpack.config.js new file mode 100644 index 00000000..f2c58f25 --- /dev/null +++ b/owl-bot-staging/v2beta/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CatalogService', + filename: './catalog-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From 2ba05d9c160813c98c66e83cebd3feac0eb2fec9 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 18 May 2022 23:52:53 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- owl-bot-staging/v2/.eslintignore | 7 - owl-bot-staging/v2/.eslintrc.json | 3 - owl-bot-staging/v2/.gitignore | 14 - owl-bot-staging/v2/.jsdoc.js | 55 - owl-bot-staging/v2/.mocharc.js | 33 - owl-bot-staging/v2/.prettierrc.js | 22 - owl-bot-staging/v2/README.md | 1 - owl-bot-staging/v2/linkinator.config.json | 16 - owl-bot-staging/v2/package.json | 69 - .../google/cloud/retail/v2/catalog.proto | 110 - .../cloud/retail/v2/catalog_service.proto | 246 -- .../google/cloud/retail/v2/common.proto | 479 --- .../cloud/retail/v2/completion_service.proto | 198 -- .../cloud/retail/v2/import_config.proto | 394 --- .../cloud/retail/v2/prediction_service.proto | 194 -- .../google/cloud/retail/v2/product.proto | 558 ---- .../cloud/retail/v2/product_service.proto | 822 ----- .../google/cloud/retail/v2/promotion.proto | 40 - .../google/cloud/retail/v2/purge_config.proto | 79 - .../cloud/retail/v2/search_service.proto | 786 ----- .../google/cloud/retail/v2/user_event.proto | 340 --- .../cloud/retail/v2/user_event_service.proto | 190 -- .../v2/catalog_service.get_default_branch.js | 58 - .../v2/catalog_service.list_catalogs.js | 83 - .../v2/catalog_service.set_default_branch.js | 81 - .../v2/catalog_service.update_catalog.js | 70 - .../v2/completion_service.complete_query.js | 116 - ...mpletion_service.import_completion_data.js | 73 - .../v2/prediction_service.predict.js | 161 - .../product_service.add_fulfillment_places.js | 115 - .../product_service.add_local_inventories.js | 99 - .../v2/product_service.create_product.js | 80 - .../v2/product_service.delete_product.js | 74 - .../v2/product_service.get_product.js | 65 - .../v2/product_service.import_products.js | 93 - .../v2/product_service.list_products.js | 130 - ...oduct_service.remove_fulfillment_places.js | 111 - ...roduct_service.remove_local_inventories.js | 85 - .../v2/product_service.set_inventory.js | 124 - .../v2/product_service.update_product.js | 80 - .../generated/v2/search_service.search.js | 260 -- ...ippet_metadata.google.cloud.retail.v2.json | 1295 -------- .../user_event_service.collect_user_event.js | 78 - .../user_event_service.import_user_events.js | 69 - .../user_event_service.purge_user_events.js | 90 - .../user_event_service.rejoin_user_events.js | 67 - .../v2/user_event_service.write_user_event.js | 64 - owl-bot-staging/v2/src/index.ts | 35 - .../v2/src/v2/catalog_service_client.ts | 1058 ------- .../src/v2/catalog_service_client_config.json | 55 - .../v2/src/v2/catalog_service_proto_list.json | 15 - .../v2/src/v2/completion_service_client.ts | 701 ----- .../v2/completion_service_client_config.json | 45 - .../src/v2/completion_service_proto_list.json | 15 - owl-bot-staging/v2/src/v2/gapic_metadata.json | 345 --- owl-bot-staging/v2/src/v2/index.ts | 24 - .../v2/src/v2/prediction_service_client.ts | 603 ---- .../v2/prediction_service_client_config.json | 40 - .../src/v2/prediction_service_proto_list.json | 15 - .../v2/src/v2/product_service_client.ts | 2210 -------------- .../src/v2/product_service_client_config.json | 99 - .../v2/src/v2/product_service_proto_list.json | 15 - .../v2/src/v2/search_service_client.ts | 1243 -------- .../src/v2/search_service_client_config.json | 40 - .../v2/src/v2/search_service_proto_list.json | 15 - .../v2/src/v2/user_event_service_client.ts | 966 ------ .../v2/user_event_service_client_config.json | 78 - .../src/v2/user_event_service_proto_list.json | 15 - .../system-test/fixtures/sample/src/index.js | 32 - .../system-test/fixtures/sample/src/index.ts | 62 - owl-bot-staging/v2/system-test/install.ts | 49 - .../v2/test/gapic_catalog_service_v2.ts | 903 ------ .../v2/test/gapic_completion_service_v2.ts | 503 ---- .../v2/test/gapic_prediction_service_v2.ts | 343 --- .../v2/test/gapic_product_service_v2.ts | 1846 ------------ .../v2/test/gapic_search_service_v2.ts | 570 ---- .../v2/test/gapic_user_event_service_v2.ts | 888 ------ owl-bot-staging/v2/tsconfig.json | 19 - owl-bot-staging/v2/webpack.config.js | 64 - owl-bot-staging/v2alpha/.eslintignore | 7 - owl-bot-staging/v2alpha/.eslintrc.json | 3 - owl-bot-staging/v2alpha/.gitignore | 14 - owl-bot-staging/v2alpha/.jsdoc.js | 55 - owl-bot-staging/v2alpha/.mocharc.js | 33 - owl-bot-staging/v2alpha/.prettierrc.js | 22 - owl-bot-staging/v2alpha/README.md | 1 - .../v2alpha/linkinator.config.json | 16 - owl-bot-staging/v2alpha/package.json | 71 - .../google/cloud/retail/v2alpha/catalog.proto | 397 --- .../retail/v2alpha/catalog_service.proto | 478 --- .../google/cloud/retail/v2alpha/common.proto | 761 ----- .../retail/v2alpha/completion_service.proto | 199 -- .../google/cloud/retail/v2alpha/control.proto | 92 - .../retail/v2alpha/control_service.proto | 184 -- .../cloud/retail/v2alpha/export_config.proto | 77 - .../cloud/retail/v2alpha/import_config.proto | 397 --- .../retail/v2alpha/prediction_service.proto | 194 -- .../google/cloud/retail/v2alpha/product.proto | 567 ---- .../retail/v2alpha/product_service.proto | 882 ------ .../cloud/retail/v2alpha/promotion.proto | 40 - .../cloud/retail/v2alpha/purge_config.proto | 171 -- .../cloud/retail/v2alpha/search_service.proto | 832 ------ .../cloud/retail/v2alpha/serving_config.proto | 247 -- .../v2alpha/serving_config_service.proto | 241 -- .../cloud/retail/v2alpha/user_event.proto | 344 --- .../retail/v2alpha/user_event_service.proto | 190 -- .../catalog_service.add_catalog_attribute.js | 65 - .../catalog_service.get_attributes_config.js | 59 - .../catalog_service.get_completion_config.js | 59 - .../catalog_service.get_default_branch.js | 58 - .../v2alpha/catalog_service.list_catalogs.js | 83 - ...atalog_service.remove_catalog_attribute.js | 65 - ...talog_service.replace_catalog_attribute.js | 73 - .../catalog_service.set_default_branch.js | 81 - ...atalog_service.update_attributes_config.js | 67 - .../v2alpha/catalog_service.update_catalog.js | 70 - ...atalog_service.update_completion_config.js | 75 - .../completion_service.complete_query.js | 117 - ...mpletion_service.import_completion_data.js | 73 - .../v2alpha/control_service.create_control.js | 72 - .../v2alpha/control_service.delete_control.js | 59 - .../v2alpha/control_service.get_control.js | 59 - .../v2alpha/control_service.list_controls.js | 79 - .../v2alpha/control_service.update_control.js | 66 - .../v2alpha/prediction_service.predict.js | 161 - .../product_service.add_fulfillment_places.js | 115 - .../product_service.add_local_inventories.js | 100 - .../v2alpha/product_service.create_product.js | 80 - .../v2alpha/product_service.delete_product.js | 75 - .../v2alpha/product_service.get_product.js | 65 - .../product_service.import_products.js | 93 - .../v2alpha/product_service.list_products.js | 141 - .../v2alpha/product_service.purge_products.js | 101 - ...oduct_service.remove_fulfillment_places.js | 111 - ...roduct_service.remove_local_inventories.js | 85 - .../v2alpha/product_service.set_inventory.js | 124 - .../v2alpha/product_service.update_product.js | 80 - .../v2alpha/search_service.search.js | 281 -- .../serving_config_service.add_control.js | 65 - ...ng_config_service.create_serving_config.js | 72 - ...ng_config_service.delete_serving_config.js | 59 - ...rving_config_service.get_serving_config.js | 59 - ...ing_config_service.list_serving_configs.js | 72 - .../serving_config_service.remove_control.js | 65 - ...ng_config_service.update_serving_config.js | 66 - ..._metadata.google.cloud.retail.v2alpha.json | 2187 -------------- .../user_event_service.collect_user_event.js | 78 - .../user_event_service.import_user_events.js | 69 - .../user_event_service.purge_user_events.js | 91 - .../user_event_service.rejoin_user_events.js | 67 - .../user_event_service.write_user_event.js | 64 - owl-bot-staging/v2alpha/src/index.ts | 39 - .../src/v2alpha/catalog_service_client.ts | 1865 ------------ .../catalog_service_client_config.json | 90 - .../v2alpha/catalog_service_proto_list.json | 20 - .../src/v2alpha/completion_service_client.ts | 936 ------ .../completion_service_client_config.json | 45 - .../completion_service_proto_list.json | 20 - .../src/v2alpha/control_service_client.ts | 1195 -------- .../control_service_client_config.json | 46 - .../v2alpha/control_service_proto_list.json | 20 - .../v2alpha/src/v2alpha/gapic_metadata.json | 581 ---- owl-bot-staging/v2alpha/src/v2alpha/index.ts | 26 - .../src/v2alpha/prediction_service_client.ts | 837 ------ .../prediction_service_client_config.json | 40 - .../prediction_service_proto_list.json | 20 - .../src/v2alpha/product_service_client.ts | 2641 ----------------- .../product_service_client_config.json | 104 - .../v2alpha/product_service_proto_list.json | 20 - .../src/v2alpha/search_service_client.ts | 1537 ---------- .../v2alpha/search_service_client_config.json | 40 - .../v2alpha/search_service_proto_list.json | 20 - .../v2alpha/serving_config_service_client.ts | 1334 --------- .../serving_config_service_client_config.json | 54 - .../serving_config_service_proto_list.json | 20 - .../src/v2alpha/user_event_service_client.ts | 1201 -------- .../user_event_service_client_config.json | 78 - .../user_event_service_proto_list.json | 20 - .../system-test/fixtures/sample/src/index.js | 34 - .../system-test/fixtures/sample/src/index.ts | 74 - .../v2alpha/system-test/install.ts | 49 - .../test/gapic_catalog_service_v2alpha.ts | 1790 ----------- .../test/gapic_completion_service_v2alpha.ts | 703 ----- .../test/gapic_control_service_v2alpha.ts | 1108 ------- .../test/gapic_prediction_service_v2alpha.ts | 543 ---- .../test/gapic_product_service_v2alpha.ts | 2190 -------------- .../test/gapic_search_service_v2alpha.ts | 770 ----- .../gapic_serving_config_service_v2alpha.ts | 1302 -------- .../test/gapic_user_event_service_v2alpha.ts | 1088 ------- owl-bot-staging/v2alpha/tsconfig.json | 19 - owl-bot-staging/v2alpha/webpack.config.js | 64 - owl-bot-staging/v2beta/.eslintignore | 7 - owl-bot-staging/v2beta/.eslintrc.json | 3 - owl-bot-staging/v2beta/.gitignore | 14 - owl-bot-staging/v2beta/.jsdoc.js | 55 - owl-bot-staging/v2beta/.mocharc.js | 33 - owl-bot-staging/v2beta/.prettierrc.js | 22 - owl-bot-staging/v2beta/README.md | 1 - owl-bot-staging/v2beta/linkinator.config.json | 16 - owl-bot-staging/v2beta/package.json | 71 - .../google/cloud/retail/v2beta/catalog.proto | 397 --- .../cloud/retail/v2beta/catalog_service.proto | 478 --- .../google/cloud/retail/v2beta/common.proto | 760 ----- .../retail/v2beta/completion_service.proto | 199 -- .../google/cloud/retail/v2beta/control.proto | 84 - .../cloud/retail/v2beta/control_service.proto | 184 -- .../cloud/retail/v2beta/export_config.proto | 77 - .../cloud/retail/v2beta/import_config.proto | 397 --- .../retail/v2beta/prediction_service.proto | 194 -- .../google/cloud/retail/v2beta/product.proto | 566 ---- .../cloud/retail/v2beta/product_service.proto | 829 ------ .../cloud/retail/v2beta/promotion.proto | 40 - .../cloud/retail/v2beta/purge_config.proto | 80 - .../cloud/retail/v2beta/search_service.proto | 791 ----- .../cloud/retail/v2beta/serving_config.proto | 247 -- .../v2beta/serving_config_service.proto | 240 -- .../cloud/retail/v2beta/user_event.proto | 342 --- .../retail/v2beta/user_event_service.proto | 190 -- .../catalog_service.add_catalog_attribute.js | 65 - .../catalog_service.get_attributes_config.js | 59 - .../catalog_service.get_completion_config.js | 59 - .../catalog_service.get_default_branch.js | 58 - .../v2beta/catalog_service.list_catalogs.js | 83 - ...atalog_service.remove_catalog_attribute.js | 65 - ...talog_service.replace_catalog_attribute.js | 73 - .../catalog_service.set_default_branch.js | 81 - ...atalog_service.update_attributes_config.js | 67 - .../v2beta/catalog_service.update_catalog.js | 70 - ...atalog_service.update_completion_config.js | 75 - .../completion_service.complete_query.js | 117 - ...mpletion_service.import_completion_data.js | 73 - .../v2beta/control_service.create_control.js | 72 - .../v2beta/control_service.delete_control.js | 59 - .../v2beta/control_service.get_control.js | 59 - .../v2beta/control_service.list_controls.js | 79 - .../v2beta/control_service.update_control.js | 66 - .../v2beta/prediction_service.predict.js | 161 - .../product_service.add_fulfillment_places.js | 115 - .../product_service.add_local_inventories.js | 100 - .../v2beta/product_service.create_product.js | 80 - .../v2beta/product_service.delete_product.js | 75 - .../v2beta/product_service.get_product.js | 65 - .../v2beta/product_service.import_products.js | 93 - .../v2beta/product_service.list_products.js | 132 - ...oduct_service.remove_fulfillment_places.js | 111 - ...roduct_service.remove_local_inventories.js | 85 - .../v2beta/product_service.set_inventory.js | 124 - .../v2beta/product_service.update_product.js | 80 - .../generated/v2beta/search_service.search.js | 261 -- .../serving_config_service.add_control.js | 65 - ...ng_config_service.create_serving_config.js | 72 - ...ng_config_service.delete_serving_config.js | 59 - ...rving_config_service.get_serving_config.js | 59 - ...ing_config_service.list_serving_configs.js | 72 - .../serving_config_service.remove_control.js | 65 - ...ng_config_service.update_serving_config.js | 66 - ...t_metadata.google.cloud.retail.v2beta.json | 2131 ------------- .../user_event_service.collect_user_event.js | 78 - .../user_event_service.import_user_events.js | 69 - .../user_event_service.purge_user_events.js | 91 - .../user_event_service.rejoin_user_events.js | 67 - .../user_event_service.write_user_event.js | 64 - owl-bot-staging/v2beta/src/index.ts | 39 - .../src/v2beta/catalog_service_client.ts | 1865 ------------ .../v2beta/catalog_service_client_config.json | 90 - .../v2beta/catalog_service_proto_list.json | 20 - .../src/v2beta/completion_service_client.ts | 936 ------ .../completion_service_client_config.json | 45 - .../v2beta/completion_service_proto_list.json | 20 - .../src/v2beta/control_service_client.ts | 1195 -------- .../v2beta/control_service_client_config.json | 46 - .../v2beta/control_service_proto_list.json | 20 - .../v2beta/src/v2beta/gapic_metadata.json | 571 ---- owl-bot-staging/v2beta/src/v2beta/index.ts | 26 - .../src/v2beta/prediction_service_client.ts | 837 ------ .../prediction_service_client_config.json | 40 - .../v2beta/prediction_service_proto_list.json | 20 - .../src/v2beta/product_service_client.ts | 2455 --------------- .../v2beta/product_service_client_config.json | 99 - .../v2beta/product_service_proto_list.json | 20 - .../src/v2beta/search_service_client.ts | 1480 --------- .../v2beta/search_service_client_config.json | 40 - .../src/v2beta/search_service_proto_list.json | 20 - .../v2beta/serving_config_service_client.ts | 1333 --------- .../serving_config_service_client_config.json | 54 - .../serving_config_service_proto_list.json | 20 - .../src/v2beta/user_event_service_client.ts | 1201 -------- .../user_event_service_client_config.json | 78 - .../v2beta/user_event_service_proto_list.json | 20 - .../system-test/fixtures/sample/src/index.js | 34 - .../system-test/fixtures/sample/src/index.ts | 74 - owl-bot-staging/v2beta/system-test/install.ts | 49 - .../test/gapic_catalog_service_v2beta.ts | 1790 ----------- .../test/gapic_completion_service_v2beta.ts | 703 ----- .../test/gapic_control_service_v2beta.ts | 1108 ------- .../test/gapic_prediction_service_v2beta.ts | 543 ---- .../test/gapic_product_service_v2beta.ts | 2046 ------------- .../test/gapic_search_service_v2beta.ts | 770 ----- .../gapic_serving_config_service_v2beta.ts | 1302 -------- .../test/gapic_user_event_service_v2beta.ts | 1088 ------- owl-bot-staging/v2beta/tsconfig.json | 19 - owl-bot-staging/v2beta/webpack.config.js | 64 - .../google/cloud/retail/v2alpha/catalog.proto | 4 +- .../google/cloud/retail/v2beta/catalog.proto | 4 +- 304 files changed, 4 insertions(+), 90413 deletions(-) delete mode 100644 owl-bot-staging/v2/.eslintignore delete mode 100644 owl-bot-staging/v2/.eslintrc.json delete mode 100644 owl-bot-staging/v2/.gitignore delete mode 100644 owl-bot-staging/v2/.jsdoc.js delete mode 100644 owl-bot-staging/v2/.mocharc.js delete mode 100644 owl-bot-staging/v2/.prettierrc.js delete mode 100644 owl-bot-staging/v2/README.md delete mode 100644 owl-bot-staging/v2/linkinator.config.json delete mode 100644 owl-bot-staging/v2/package.json delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto delete mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/search_service.search.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/v2/src/index.ts delete mode 100644 owl-bot-staging/v2/src/v2/catalog_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/catalog_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/catalog_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/completion_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/completion_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/completion_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/gapic_metadata.json delete mode 100644 owl-bot-staging/v2/src/v2/index.ts delete mode 100644 owl-bot-staging/v2/src/v2/prediction_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/prediction_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/prediction_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/product_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/product_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/product_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/search_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/search_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/search_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/user_event_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/user_event_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v2/system-test/install.ts delete mode 100644 owl-bot-staging/v2/test/gapic_catalog_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_completion_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_prediction_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_product_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_search_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_user_event_service_v2.ts delete mode 100644 owl-bot-staging/v2/tsconfig.json delete mode 100644 owl-bot-staging/v2/webpack.config.js delete mode 100644 owl-bot-staging/v2alpha/.eslintignore delete mode 100644 owl-bot-staging/v2alpha/.eslintrc.json delete mode 100644 owl-bot-staging/v2alpha/.gitignore delete mode 100644 owl-bot-staging/v2alpha/.jsdoc.js delete mode 100644 owl-bot-staging/v2alpha/.mocharc.js delete mode 100644 owl-bot-staging/v2alpha/.prettierrc.js delete mode 100644 owl-bot-staging/v2alpha/README.md delete mode 100644 owl-bot-staging/v2alpha/linkinator.config.json delete mode 100644 owl-bot-staging/v2alpha/package.json delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/v2alpha/src/index.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/index.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v2alpha/system-test/install.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/tsconfig.json delete mode 100644 owl-bot-staging/v2alpha/webpack.config.js delete mode 100644 owl-bot-staging/v2beta/.eslintignore delete mode 100644 owl-bot-staging/v2beta/.eslintrc.json delete mode 100644 owl-bot-staging/v2beta/.gitignore delete mode 100644 owl-bot-staging/v2beta/.jsdoc.js delete mode 100644 owl-bot-staging/v2beta/.mocharc.js delete mode 100644 owl-bot-staging/v2beta/.prettierrc.js delete mode 100644 owl-bot-staging/v2beta/README.md delete mode 100644 owl-bot-staging/v2beta/linkinator.config.json delete mode 100644 owl-bot-staging/v2beta/package.json delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/v2beta/src/index.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/index.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v2beta/system-test/install.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/tsconfig.json delete mode 100644 owl-bot-staging/v2beta/webpack.config.js diff --git a/owl-bot-staging/v2/.eslintignore b/owl-bot-staging/v2/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v2/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v2/.eslintrc.json b/owl-bot-staging/v2/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v2/.gitignore b/owl-bot-staging/v2/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v2/.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/v2/.jsdoc.js b/owl-bot-staging/v2/.jsdoc.js deleted file mode 100644 index 19729810..00000000 --- a/owl-bot-staging/v2/.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/retail', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v2/.mocharc.js b/owl-bot-staging/v2/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v2/.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/v2/.prettierrc.js b/owl-bot-staging/v2/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v2/.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/v2/README.md b/owl-bot-staging/v2/README.md deleted file mode 100644 index 822c4573..00000000 --- a/owl-bot-staging/v2/README.md +++ /dev/null @@ -1 +0,0 @@ -Retail: Nodejs Client diff --git a/owl-bot-staging/v2/linkinator.config.json b/owl-bot-staging/v2/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v2/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/v2/package.json b/owl-bot-staging/v2/package.json deleted file mode 100644 index 09d9ddf3..00000000 --- a/owl-bot-staging/v2/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@google-cloud/retail", - "version": "0.1.0", - "description": "Retail client for Node.js", - "repository": "googleapis/nodejs-retail", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google retail", - "retail", - "catalog service", - "completion service", - "prediction service", - "product service", - "search service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto deleted file mode 100644 index b5de698d..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Configures what level the product should be uploaded with regards to -// how users will be send events and how predictions will be made. -message ProductLevelConfig { - // The type of [Product][google.cloud.retail.v2.Product]s allowed to be - // ingested into the catalog. Acceptable values are: - // - // * `primary` (default): You can ingest - // [Product][google.cloud.retail.v2.Product]s of all types. When - // ingesting a [Product][google.cloud.retail.v2.Product], its type will - // default to - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] if - // unset. - // * `variant`: You can only ingest - // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s. - // This means - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] - // cannot be empty. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `variant` and - // [merchant_center_product_id_field][google.cloud.retail.v2.ProductLevelConfig.merchant_center_product_id_field] - // is `itemGroupId`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string ingestion_product_type = 1; - - // Which field of [Merchant Center - // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be - // imported as [Product.id][google.cloud.retail.v2.Product.id]. Acceptable - // values are: - // - // * `offerId` (default): Import `offerId` as the product ID. - // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail - // API will choose one item from the ones with the same `itemGroupId`, and - // use it to represent the item group. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `itemGroupId` and - // [ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] - // is `variant`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string merchant_center_product_id_field = 2; -} - -// The catalog configuration. -message Catalog { - option (google.api.resource) = { - type: "retail.googleapis.com/Catalog" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" - }; - - // Required. Immutable. The fully qualified resource name of the catalog. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. Immutable. The catalog display name. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. The product level configuration. - ProductLevelConfig product_level_config = 4 - [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto deleted file mode 100644 index ec7a23a8..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/catalog.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for managing catalog configuration. -service CatalogService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with - // the project. - rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*}/catalogs" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates the [Catalog][google.cloud.retail.v2.Catalog]s. - rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { - option (google.api.http) = { - patch: "/v2/{catalog.name=projects/*/locations/*/catalogs/*}" - body: "catalog" - }; - option (google.api.method_signature) = "catalog,update_mask"; - } - - // Set a specified branch id as default branch. API methods such as - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search], - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] - // will treat requests using "default_branch" to the actual branch id set as - // default. - // - // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as - // default, setting - // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent - // to setting - // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/1`. - // - // Using multiple branches can be useful when developers would like - // to have a staging branch to test and verify for future usage. When it - // becomes ready, developers switch on the staging branch using this API while - // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` - // as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to - // route the traffic to this staging branch. - // - // CAUTION: If you have live predict/search traffic, switching the default - // branch could potentially cause outages if the ID space of the new branch is - // very different from the old one. - // - // More specifically: - // - // * PredictionService will only return product IDs from branch {newBranch}. - // * SearchService will only return product IDs from branch {newBranch} - // (if branch is not explicitly set). - // * UserEventService will only join events with products from branch - // {newBranch}. - rpc SetDefaultBranch(SetDefaultBranchRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" - body: "*" - }; - option (google.api.method_signature) = "catalog"; - } - - // Get which branch is currently default branch set by - // [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] - // method under a specified parent catalog. - rpc GetDefaultBranch(GetDefaultBranchRequest) - returns (GetDefaultBranchResponse) { - option (google.api.http) = { - get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" - }; - option (google.api.method_signature) = "catalog"; - } -} - -// Request for -// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] -// method. -message ListCatalogsRequest { - // Required. The account resource name with an associated location. - // - // If the caller does not have permission to list - // [Catalog][google.cloud.retail.v2.Catalog]s under this location, regardless - // of whether or not this location exists, a PERMISSION_DENIED error is - // returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of [Catalog][google.cloud.retail.v2.Catalog]s to return. If - // unspecified, defaults to 50. The maximum allowed value is 1000. Values - // above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 2; - - // A page token - // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2.ListCatalogsResponse.next_page_token], - // received from a previous - // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; -} - -// Response for -// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] -// method. -message ListCatalogsResponse { - // All the customer's [Catalog][google.cloud.retail.v2.Catalog]s. - repeated Catalog catalogs = 1; - - // A token that can be sent as - // [ListCatalogsRequest.page_token][google.cloud.retail.v2.ListCatalogsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request for -// [CatalogService.UpdateCatalog][google.cloud.retail.v2.CatalogService.UpdateCatalog] -// method. -message UpdateCatalogRequest { - // Required. The [Catalog][google.cloud.retail.v2.Catalog] to update. - // - // If the caller does not have permission to update the - // [Catalog][google.cloud.retail.v2.Catalog], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // If the [Catalog][google.cloud.retail.v2.Catalog] to update does not exist, - // a NOT_FOUND error is returned. - Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Catalog][google.cloud.retail.v2.Catalog] to update. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message to set a specified branch as new default_branch. -message SetDefaultBranchRequest { - // Full resource name of the catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // The final component of the resource name of a branch. - // - // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - // error is returned. - // - // If there are no sufficient active products in the targeted branch and - // [force][google.cloud.retail.v2.SetDefaultBranchRequest.force] is not set, a - // FAILED_PRECONDITION error is returned. - string branch_id = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Some note on this request, this can be retrieved by - // [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch] - // before next valid default branch set occurs. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string note = 3; - - // If set to true, it permits switching to a branch with - // [branch_id][google.cloud.retail.v2.SetDefaultBranchRequest.branch_id] even - // if it has no sufficient active products. - bool force = 4; -} - -// Request message to show which branch is currently the default branch. -message GetDefaultBranchRequest { - // The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; -} - -// Response message of -// [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch]. -message GetDefaultBranchResponse { - // Full resource name of the branch id currently set as default branch. - string branch = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // The time when this branch is set to default. - google.protobuf.Timestamp set_time = 2; - - // This corresponds to - // [SetDefaultBranchRequest.note][google.cloud.retail.v2.SetDefaultBranchRequest.note] - // field, when this branch was set as default. - string note = 3; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto deleted file mode 100644 index 733b8cca..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto +++ /dev/null @@ -1,479 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// An intended audience of the [Product][google.cloud.retail.v2.Product] for -// whom it's sold. -message Audience { - // The genders of the audience. Strongly encouraged to use the standard - // values: "male", "female", "unisex". - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [gender](https://support.google.com/merchants/answer/6324479). Schema.org - // property - // [Product.audience.suggestedGender](https://schema.org/suggestedGender). - repeated string genders = 1; - - // The age groups of the audience. Strongly encouraged to use the standard - // values: "newborn" (up to 3 months old), "infant" (3–12 months old), - // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically - // teens or older). - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [age_group](https://support.google.com/merchants/answer/6324463). - // Schema.org property - // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and - // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). - repeated string age_groups = 2; -} - -// The color information of a [Product][google.cloud.retail.v2.Product]. -message ColorInfo { - // The standard color families. Strongly recommended to use the following - // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", - // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and - // "Mixed". Normally it is expected to have only 1 color family. May consider - // using single "Mixed" instead of multiple values. - // - // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string color_families = 1; - - // The color display names, which may be different from standard color family - // names, such as the color aliases used in the website frontend. Normally - // it is expected to have only 1 color. May consider using single "Mixed" - // instead of multiple values. - // - // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string colors = 2; -} - -// A custom attribute that is not explicitly modeled in -// [Product][google.cloud.retail.v2.Product]. -message CustomAttribute { - // The textual values of this custom attribute. For example, `["yellow", - // "green"]` when the key is "color". - // - // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated string text = 1; - - // The numerical values of this custom attribute. For example, `[2.3, 15.4]` - // when the key is "lengths_cm". - // - // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated double numbers = 2; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][] of the - // [Catalog][google.cloud.retail.v2.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - // - // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. - // - // Only set if type [text][google.cloud.retail.v2.CustomAttribute.text] is - // set. Otherwise, a INVALID_ARGUMENT error is returned. - optional bool searchable = 3; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][] of the - // [Catalog][google.cloud.retail.v2.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // indexed, so that it can be filtered, faceted or boosted in - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - // - // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. - // - // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter], - // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] - // and - // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] - // for more details. - optional bool indexable = 4; -} - -// Fulfillment information, such as the store IDs for in-store pickup or region -// IDs for different shipping methods. -message FulfillmentInfo { - // The fulfillment type, including commonly used types (such as pickup in - // store and same day delivery), and custom types. Customers have to map - // custom types to their display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - string type = 1; - - // The IDs for this [type][google.cloud.retail.v2.FulfillmentInfo.type], such - // as the store IDs for - // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2.FulfillmentInfo.type] - // or the region IDs for - // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2.FulfillmentInfo.type]. - // - // A maximum of 3000 values are allowed. Each value must be a string with a - // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such - // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string place_ids = 2; -} - -// [Product][google.cloud.retail.v2.Product] image. Recommendations AI and -// Retail Search do not use product images to improve prediction and search -// results. However, product images can be returned in results, and are shown in -// prediction or search previews in the console. -message Image { - // Required. URI of the image. - // - // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // Height of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 height = 2; - - // Width of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 width = 3; -} - -// A floating point interval. -message Interval { - // The lower bound of the interval. If neither of the min fields are set, then - // the lower bound is negative infinity. - // - // This field must be not larger than - // [max][google.cloud.retail.v2.Interval.max]. Otherwise, an INVALID_ARGUMENT - // error is returned. - oneof min { - // Inclusive lower bound. - double minimum = 1; - - // Exclusive lower bound. - double exclusive_minimum = 2; - } - - // The upper bound of the interval. If neither of the max fields are set, then - // the upper bound is positive infinity. - // - // This field must be not smaller than - // [min][google.cloud.retail.v2.Interval.min]. Otherwise, an INVALID_ARGUMENT - // error is returned. - oneof max { - // Inclusive upper bound. - double maximum = 3; - - // Exclusive upper bound. - double exclusive_maximum = 4; - } -} - -// The price information of a [Product][google.cloud.retail.v2.Product]. -message PriceInfo { - // The price range of all - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. - message PriceRange { - // The inclusive - // [Product.pricing_info.price][google.cloud.retail.v2.PriceInfo.price] - // interval of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. - Interval price = 1; - - // The inclusive - // [Product.pricing_info.original_price][google.cloud.retail.v2.PriceInfo.original_price] - // internal of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. - Interval original_price = 2; - } - - // The 3-letter currency code defined in [ISO - // 4217](https://www.iso.org/iso-4217-currency-codes.html). - // - // If this field is an unrecognizable currency code, an INVALID_ARGUMENT - // error is returned. - // - // The [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s with the same - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] - // must share the same - // [currency_code][google.cloud.retail.v2.PriceInfo.currency_code]. Otherwise, - // a FAILED_PRECONDITION error is returned. - string currency_code = 1; - - // Price of the product. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). Schema.org - // property [Offer.price](https://schema.org/price). - float price = 2; - - // Price of the product without any discount. If zero, by default set to be - // the [price][google.cloud.retail.v2.PriceInfo.price]. - float original_price = 3; - - // The costs associated with the sale of a particular product. Used for gross - // profit reporting. - // - // * Profit = [price][google.cloud.retail.v2.PriceInfo.price] - - // [cost][google.cloud.retail.v2.PriceInfo.cost] - // - // Google Merchant Center property - // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). - float cost = 4; - - // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] - // starts to be effective. This can be set as a future timestamp, and the - // [price][google.cloud.retail.v2.PriceInfo.price] is only used for search - // after - // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. - // If so, the - // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be - // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] - // is used before - // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. - // - // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always - // effective because it will cause additional latency during search. - google.protobuf.Timestamp price_effective_time = 5; - - // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] - // stops to be effective. The [price][google.cloud.retail.v2.PriceInfo.price] - // is used for search before - // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. If - // this field is set, the - // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be - // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] - // is used after - // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. - // - // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always - // effective because it will cause additional latency during search. - google.protobuf.Timestamp price_expire_time = 6; - - // Output only. The price range of all the child - // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s grouped together on the - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]. Only populated for - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. - // Do not set this field in API requests. - PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The rating of a [Product][google.cloud.retail.v2.Product]. -message Rating { - // The total number of ratings. This value is independent of the value of - // [rating_histogram][google.cloud.retail.v2.Rating.rating_histogram]. - // - // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 rating_count = 1; - - // The average rating of the [Product][google.cloud.retail.v2.Product]. - // - // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is - // returned. - float average_rating = 2; - - // List of rating counts per rating value (index = rating - 1). The list is - // empty if there is no rating. If the list is non-empty, its size is - // always 5. Otherwise, an INVALID_ARGUMENT error is returned. - // - // For example, [41, 14, 13, 47, 303]. It means that the - // [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 - // ratings with 2 star, and so on. - repeated int32 rating_histogram = 3; -} - -// Information of an end user. -message UserInfo { - // Highly recommended for logged-in users. Unique identifier for logged-in - // user, such as a user name. - // - // Always use a hashed value for this ID. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string user_id = 1; - - // The end user's IP address. This field is used to extract location - // information for personalization. - // - // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 - // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This should not be set when: - // - // * setting - // [SearchRequest.user_info][google.cloud.retail.v2.SearchRequest.user_info]. - // * using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] - // is set. - string ip_address = 2; - - // User agent as included in the HTTP header. Required for getting - // [SearchResponse.sponsored_results][google.cloud.retail.v2.SearchResponse.sponsored_results]. - // - // The field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This should not be set when using the client side event reporting with - // GTM or JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] - // is set. - string user_agent = 3; - - // True if the request is made directly from the end user, in which case the - // [ip_address][google.cloud.retail.v2.UserInfo.ip_address] and - // [user_agent][google.cloud.retail.v2.UserInfo.user_agent] can be populated - // from the HTTP request. This flag should be set only if the API request is - // made directly from the end user such as a mobile app (and not if a gateway - // or a server is processing and pushing the user events). - // - // This should not be set when using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent]. - bool direct_user_request = 4; -} - -// The inventory information at a place (e.g. a store) identified -// by a place ID. -message LocalInventory { - // The place ID for the current set of inventory information. - string place_id = 1; - - // Product price and cost information. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 2; - - // Additional local inventory attributes, for example, store name, promotion - // tags, etc. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * At most 30 attributes are allowed. - // * The key must be a UTF-8 encoded string with a length limit of 32 - // characters. - // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, - // key0LikeThis or KEY_1_LIKE_THIS. - // * The attribute values must be of the same type (text or number). - // * Only 1 value is allowed for each attribute. - // * For text values, the length limit is 256 UTF-8 characters. - // * The attribute does not support search. The `searchable` field should be - // unset or set to false. - // * The max summed total bytes of custom attribute keys and values per - // product is 5MiB. - map attributes = 3; - - // Input only. Supported fulfillment types. Valid fulfillment type values - // include commonly used types (such as pickup in store and same day - // delivery), and custom types. Customers have to map custom types to their - // display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string fulfillment_types = 4 - [(google.api.field_behavior) = INPUT_ONLY]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto deleted file mode 100644 index 5e7e9a6c..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/import_config.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "CompletionServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Auto-completion service for retail. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service CompletionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Completes the specified prefix with keyword suggestions. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { - option (google.api.http) = { - get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" - }; - } - - // Bulk import of processed completion dataset. - // - // Request processing is asynchronous. Partial updating is not supported. - // - // The operation is successfully finished only after the imported suggestions - // are indexed successfully and ready for serving. The process takes hours. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc ImportCompletionData(ImportCompletionDataRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.ImportCompletionDataResponse" - metadata_type: "google.cloud.retail.v2.ImportMetadata" - }; - } -} - -// Auto-complete parameters. -message CompleteQueryRequest { - // Required. Catalog for which the completion is performed. - // - // Full resource name of catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The query used to generate suggestions. - // - // The maximum number of allowed characters is 255. - string query = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required field. A unique identifier for tracking visitors. For example, - // this could be implemented with an HTTP cookie, which should be able to - // uniquely identify a visitor on a single device. This unique identifier - // should not change if the visitor logs in or out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 7; - - // The language filters applied to the output suggestions. If set, it should - // contain the language of the query. If not set, suggestions are returned - // without considering language restrictions. This is the BCP-47 language - // code, such as "en-US" or "sr-Latn". For more information, see [Tags for - // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - // number of language codes is 3. - repeated string language_codes = 3; - - // The device type context for completion suggestions. - // It is useful to apply different suggestions on different device types, e.g. - // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - // types. - // - // Supported formats: - // - // * `UNKNOWN_DEVICE_TYPE` - // - // * `DESKTOP` - // - // * `MOBILE` - // - // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - string device_type = 4; - - // Determines which dataset to use for fetching completion. "user-data" will - // use the imported dataset through - // [CompletionService.ImportCompletionData][google.cloud.retail.v2.CompletionService.ImportCompletionData]. - // "cloud-retail" will use the dataset generated by cloud retail based on user - // events. If leave empty, it will use the "user-data". - // - // Current supported values: - // - // * user-data - // - // * cloud-retail - // This option requires additional allowlisting. Before using cloud-retail, - // contact Cloud Retail support team first. - string dataset = 6; - - // Completion max suggestions. If left unset or set to 0, then will fallback - // to the configured value [CompletionConfig.max_suggestions][]. - // - // The maximum allowed max suggestions is 20. If it is set higher, it will be - // capped by 20. - int32 max_suggestions = 5; -} - -// Response of the auto-complete query. -message CompleteQueryResponse { - // Resource that represents completion results. - message CompletionResult { - // The suggestion for the query. - string suggestion = 1; - - // Custom attributes for the suggestion term. - // * For "user-data", the attributes are additional custom attributes - // ingested through BigQuery. - // * For "cloud-retail", the attributes are product attributes generated - // by Cloud Retail. - map attributes = 2; - } - - // Recent search of this user. - message RecentSearchResult { - // The recent search query. - string recent_search = 1; - } - - // Results of the matching suggestions. The result list is ordered and the - // first result is top suggestion. - repeated CompletionResult completion_results = 1; - - // A unique complete token. This should be included in the - // [UserEvent.completion_detail][google.cloud.retail.v2.UserEvent.completion_detail] - // for search events resulting from this completion, which enables accurate - // attribution of complete model performance. - string attribution_token = 2; - - // Matched recent searches of this user. The maximum number of recent searches - // is 10. This field is a restricted feature. Contact Retail Search support - // team if you are interested in enabling it. - // - // This feature is only available when - // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2.CompleteQueryRequest.visitor_id] - // field is set and [UserEvent][google.cloud.retail.v2.UserEvent] is imported. - // The recent searches satisfy the follow rules: - // * They are ordered from latest to oldest. - // * They are matched with - // [CompleteQueryRequest.query][google.cloud.retail.v2.CompleteQueryRequest.query] - // case insensitively. - // * They are transformed to lower cases. - // * They are UTF-8 safe. - // - // Recent searches are deduplicated. More recent searches will be reserved - // when duplication happens. - repeated RecentSearchResult recent_search_results = 3; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto deleted file mode 100644 index 74cec22a..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto +++ /dev/null @@ -1,394 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/product.proto"; -import "google/cloud/retail/v2/user_event.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "ImportConfigProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Google Cloud Storage location for input content. -// format. -message GcsSource { - // Required. Google Cloud Storage URIs to input files. URI can be up to - // 2000 characters long. URIs can match the full object path (for example, - // `gs://bucket/directory/object.json`) or a pattern matching one or more - // files, such as `gs://bucket/directory/*.json`. A request can - // contain at most 100 files, and each file can be up to 2 GB. See - // [Importing product - // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) - // for the expected file format and setup instructions. - repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] - // per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2.UserEvent] per line. - // * `user_event_ga360`: Using - // https://support.google.com/analytics/answer/3437719. - // - // Supported values for control imports: - // - // * 'control' (default): One JSON [Control][] per line. - // - // Supported values for catalog attribute imports: - // - // * 'catalog_attribute' (default): One CSV [CatalogAttribute][] per line. - string data_schema = 2; -} - -// BigQuery source import data from. -message BigQuerySource { - // BigQuery table partition info. Leave this empty if the BigQuery table - // is not partitioned. - oneof partition { - // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - google.type.Date partition_date = 6; - } - - // The project ID (can be project # or ID) that the BigQuery source is in with - // a length limit of 128 characters. If not specified, inherits the project - // ID from the parent request. - string project_id = 5; - - // Required. The BigQuery data set to copy the data from with a length limit - // of 1,024 characters. - string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The BigQuery table to copy the data from with a length limit of - // 1,024 characters. - string table_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Intermediate Cloud Storage directory used for the import with a length - // limit of 2,000 characters. Can be specified if one wants to have the - // BigQuery export to a specific Cloud Storage directory. - string gcs_staging_dir = 3; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] - // per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2.UserEvent] per line. - // * `user_event_ga360`: - // The schema is available here: - // https://support.google.com/analytics/answer/3437719. - // * `user_event_ga4`: This feature is in private preview. Please contact the - // support team for importing Google Analytics 4 events. - // The schema is available here: - // https://support.google.com/analytics/answer/7029846. - // - // Supported values for auto-completion imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - string data_schema = 4; -} - -// The inline source for the input config for ImportProducts method. -message ProductInlineSource { - // Required. A list of products to update/create. Each product must have a - // valid [Product.id][google.cloud.retail.v2.Product.id]. Recommended max of - // 100 items. - repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The inline source for the input config for ImportUserEvents method. -message UserEventInlineSource { - // Required. A list of user events to import. Recommended max of 10k items. - repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Configuration of destination for Import related errors. -message ImportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage prefix for import errors. This must be an empty, - // existing Cloud Storage directory. Import errors will be written to - // sharded files in this directory, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Request message for Import methods. -message ImportProductsRequest { - // Indicates how imported products are reconciled with the existing products - // created or imported before. - enum ReconciliationMode { - // Defaults to INCREMENTAL. - RECONCILIATION_MODE_UNSPECIFIED = 0; - - // Inserts new products or updates existing products. - INCREMENTAL = 1; - - // Calculates diff and replaces the entire product dataset. Existing - // products may be deleted if they are not present in the source location. - // - // Can only be set while using - // [BigQuerySource][google.cloud.retail.v2.BigQuerySource]. And the BigQuery - // dataset must be created in the data location "us (multiple regions in - // United States)", otherwise a PERMISSION_DENIED error is thrown. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - FULL = 2; - } - - // Required. - // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - // - // If no updateMask is specified, requires products.create permission. - // If updateMask is specified, requires products.update permission. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Deprecated. This field has no effect. - string request_id = 6 [deprecated = true]; - - // Required. The desired input location of the data. - ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. - ImportErrorsConfig errors_config = 3; - - // Indicates which fields in the provided imported 'products' to update. If - // not set, will by default update all fields. - google.protobuf.FieldMask update_mask = 4; - - // The mode of reconciliation between existing products and the products to be - // imported. Defaults to - // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. - ReconciliationMode reconciliation_mode = 5; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - string notification_pubsub_topic = 7; -} - -// Request message for the ImportUserEvents request. -message ImportUserEventsRequest { - // Required. `projects/1234/locations/global/catalogs/default_catalog` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - UserEventInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. Cannot be set - // for inline user event imports. - ImportErrorsConfig errors_config = 3; -} - -// Request message for ImportCompletionData methods. -message ImportCompletionDataRequest { - // Required. The catalog which the suggestions dataset belongs to. - // - // Format: `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - CompletionDataInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 3; -} - -// The input config source for products. -message ProductInputConfig { - // Required. The source of the input. - oneof source { - // The Inline source for the input content for products. - ProductInlineSource product_inline_source = 1; - - // Google Cloud Storage location for the input content. - GcsSource gcs_source = 2; - - // BigQuery input source. - BigQuerySource big_query_source = 3; - } -} - -// The input config source for user events. -message UserEventInputConfig { - // The source of the input. - oneof source { - // Required. The Inline source for the input content for UserEvents. - UserEventInlineSource user_event_inline_source = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Google Cloud Storage location for the input content. - GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. BigQuery input source. - BigQuerySource big_query_source = 3 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// The input config source for completion data. -message CompletionDataInputConfig { - // The source of the input. - // - // Supported - // [BigQuerySource.data_schema][google.cloud.retail.v2.BigQuerySource.data_schema] - // values for suggestions imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - oneof source { - // Required. BigQuery input source. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - BigQuerySource big_query_source = 1 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// Metadata related to the progress of the Import operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ImportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; - - // Deprecated. This field is never set. - string request_id = 5 [deprecated = true]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 6; -} - -// Response of the -// [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest]. If the -// long running operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ImportErrorsConfig errors_config = 2; -} - -// Response of the ImportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ImportErrorsConfig errors_config = 2; - - // Aggregated statistics of user event import status. - UserEventImportSummary import_summary = 3; -} - -// A summary of import result. The UserEventImportSummary summarizes -// the import status for user events. -message UserEventImportSummary { - // Count of user events imported with complete existing catalog information. - int64 joined_events_count = 1; - - // Count of user events imported, but with catalog information not found - // in the imported catalog. - int64 unjoined_events_count = 2; -} - -// Response of the -// [ImportCompletionDataRequest][google.cloud.retail.v2.ImportCompletionDataRequest]. -// If the long running operation is done, this message is returned by the -// google.longrunning.Operations.response field if the operation is successful. -message ImportCompletionDataResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto deleted file mode 100644 index 061db142..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "PredictionServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for making recommendation prediction. -service PredictionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Makes a recommendation prediction. - rpc Predict(PredictRequest) returns (PredictResponse) { - option (google.api.http) = { - post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" - body: "*" - }; - } -} - -// Request message for Predict method. -message PredictRequest { - // Required. Full resource name of the format: - // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} - // The ID of the Recommendations AI placement. Before you can request - // predictions from your model, you must create at least one placement for it. - // For more information, see [Managing - // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - // - // The full list of available placements can be seen at - // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Context about the user, what they are looking at and what action - // they took to trigger the predict request. Note that this user event detail - // won't be ingested to userEvent logs. Thus, a separate userEvent write - // request is required for event logging. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // Maximum number of results to return per page. Set this property - // to the number of prediction results needed. If zero, the service will - // choose a reasonable default. The maximum allowed value is 100. Values - // above 100 will be coerced to 100. - int32 page_size = 3; - - // The previous PredictResponse.next_page_token. - string page_token = 4; - - // Filter for restricting prediction results with a length limit of 5,000 - // characters. Accepts values for tags and the `filterOutOfStockItems` flag. - // - // * Tag expressions. Restricts predictions to products that match all of the - // specified tags. Boolean operators `OR` and `NOT` are supported if the - // expression is enclosed in parentheses, and must be separated from the - // tag values by a space. `-"tagA"` is also supported and is equivalent to - // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - // with a size limit of 1,000 characters. - // - // Note: "Recently viewed" models don't support tag filtering at the - // moment. - // - // * filterOutOfStockItems. Restricts predictions to products that do not - // have a - // stockState value of OUT_OF_STOCK. - // - // Examples: - // - // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - // * filterOutOfStockItems tag=(-"promotional") - // * filterOutOfStockItems - // - // If your filter blocks all prediction results, the API will return generic - // (unfiltered) popular products. If you only want results strictly matching - // the filters, set `strictFiltering` to True in `PredictRequest.params` to - // receive empty results instead. - // Note that the API will never return items with storageStatus of "EXPIRED" - // or "DELETED" regardless of filter choices. - string filter = 5; - - // Use validate only mode for this prediction query. If set to true, a - // dummy model will be used that returns arbitrary products. - // Note that the validate only mode should only be used for testing the API, - // or if the model is not ready. - bool validate_only = 6; - - // Additional domain specific parameters for the predictions. - // - // Allowed values: - // - // * `returnProduct`: Boolean. If set to true, the associated product - // object will be returned in the `results.metadata` field in the - // prediction response. - // * `returnScore`: Boolean. If set to true, the prediction 'score' - // corresponding to each returned product will be set in the - // `results.metadata` field in the prediction response. The given - // 'score' indicates the probability of an product being clicked/purchased - // given the user's context and history. - // * `strictFiltering`: Boolean. True by default. If set to false, the service - // will return generic (unfiltered) popular products instead of empty if - // your filter blocks all prediction results. - // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-price-reranking', 'low-price-reranking', - // 'medium-price-reranking', 'high-price-reranking'}. This gives - // request-level control and adjusts prediction results based on product - // price. - // * `diversityLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-diversity', 'low-diversity', - // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - // request-level control and adjusts prediction results based on product - // category. - map params = 7; - - // The labels applied to a resource must meet the following requirements: - // - // * Each resource can have multiple labels, up to a maximum of 64. - // * Each label must be a key-value pair. - // * Keys have a minimum length of 1 character and a maximum length of 63 - // characters, and cannot be empty. Values can be empty, and have a maximum - // length of 63 characters. - // * Keys and values can contain only lowercase letters, numeric characters, - // underscores, and dashes. All characters must use UTF-8 encoding, and - // international characters are allowed. - // * The key portion of a label must be unique. However, you can use the same - // key with multiple resources. - // * Keys must start with a lowercase letter or international character. - // - // See [Google Cloud - // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - // for more details. - map labels = 8; -} - -// Response message for predict method. -message PredictResponse { - // PredictionResult represents the recommendation prediction results. - message PredictionResult { - // ID of the recommended product - string id = 1; - - // Additional product metadata / annotations. - // - // Possible values: - // - // * `product`: JSON representation of the product. Will be set if - // `returnProduct` is set to true in `PredictRequest.params`. - // * `score`: Prediction score in double value. Will be set if - // `returnScore` is set to true in `PredictRequest.params`. - map metadata = 2; - } - - // A list of recommended products. The order represents the ranking (from the - // most relevant product to the least). - repeated PredictionResult results = 1; - - // A unique attribution token. This should be included in the - // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this - // recommendation, which enables accurate attribution of recommendation model - // performance. - string attribution_token = 2; - - // IDs of products in the request that were missing from the inventory. - repeated string missing_ids = 3; - - // True if the validateOnly property was set in the request. - bool validate_only = 4; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto deleted file mode 100644 index ea861fb6..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto +++ /dev/null @@ -1,558 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/promotion.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; -option (google.api.resource_definition) = { - type: "retail.googleapis.com/Branch" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" -}; - -// Product captures all metadata information of items to be recommended or -// searched. -message Product { - option (google.api.resource) = { - type: "retail.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" - }; - - // The type of this product. - enum Type { - // Default value. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] - // if unset. - TYPE_UNSPECIFIED = 0; - - // The primary type. - // - // As the primary unit for predicting, indexing and search serving, a - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product] is grouped with multiple - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s. - PRIMARY = 1; - - // The variant type. - // - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s usually share some common - // attributes on the same - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s, but they have variant - // attributes like different colors, sizes and prices, etc. - VARIANT = 2; - - // The collection type. Collection products are bundled - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s or - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s that are sold together, such - // as a jewelry set with necklaces, earrings and rings, etc. - COLLECTION = 3; - } - - // Product availability. If this field is unspecified, the product is - // assumed to be in stock. - enum Availability { - // Default product availability. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK] - // if unset. - AVAILABILITY_UNSPECIFIED = 0; - - // Product in stock. - IN_STOCK = 1; - - // Product out of stock. - OUT_OF_STOCK = 2; - - // Product that is in pre-order state. - PREORDER = 3; - - // Product that is back-ordered (i.e. temporarily out of stock). - BACKORDER = 4; - } - - oneof expiration { - // The timestamp when this product becomes unavailable for - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - // - // If it is set, the [Product][google.cloud.retail.v2.Product] is not - // available for - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after - // [expire_time][google.cloud.retail.v2.Product.expire_time]. However, the - // product can still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // [expire_time][google.cloud.retail.v2.Product.expire_time] must be later - // than [available_time][google.cloud.retail.v2.Product.available_time] and - // [publish_time][google.cloud.retail.v2.Product.publish_time], otherwise an - // INVALID_ARGUMENT error is thrown. - // - // Corresponding properties: Google Merchant Center property - // [expiration_date](https://support.google.com/merchants/answer/6324499). - google.protobuf.Timestamp expire_time = 16; - - // Input only. The TTL (time to live) of the product. - // - // If it is set, it must be a non-negative value, and - // [expire_time][google.cloud.retail.v2.Product.expire_time] is set as - // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. The - // derived [expire_time][google.cloud.retail.v2.Product.expire_time] is - // returned in the output and [ttl][google.cloud.retail.v2.Product.ttl] is - // left blank when retrieving the [Product][google.cloud.retail.v2.Product]. - // - // If it is set, the product is not available for - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after - // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. - // However, the product can still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - google.protobuf.Duration ttl = 17 - [(google.api.field_behavior) = INPUT_ONLY]; - } - - // Immutable. Full resource name of the product, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. [Product][google.cloud.retail.v2.Product] identifier, which is - // the final component of [name][google.cloud.retail.v2.Product.name]. For - // example, this field is "id_1", if - // [name][google.cloud.retail.v2.Product.name] is - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [id](https://support.google.com/merchants/answer/6324405). Schema.org - // property [Product.sku](https://schema.org/sku). - string id = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The type of the product. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] - // if unset. - Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; - - // Variant group identifier. Must be an - // [id][google.cloud.retail.v2.Product.id], with the same parent branch with - // this product. Otherwise, an error is thrown. - // - // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s, this field can only be empty or - // set to the same value as [id][google.cloud.retail.v2.Product.id]. - // - // For VARIANT [Product][google.cloud.retail.v2.Product]s, this field cannot - // be empty. A maximum of 2,000 products are allowed to share the same - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]. Otherwise, an INVALID_ARGUMENT - // error is returned. - // - // Corresponding properties: Google Merchant Center property - // [item_group_id](https://support.google.com/merchants/answer/6324507). - // Schema.org property - // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). - string primary_product_id = 4; - - // The [id][google.cloud.retail.v2.Product.id] of the collection members when - // [type][google.cloud.retail.v2.Product.type] is - // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]. - // - // Non-existent product ids are allowed. - // The [type][google.cloud.retail.v2.Product.type] of the members must be - // either [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] or - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] otherwise and - // INVALID_ARGUMENT error is thrown. Should not set it for other types. A - // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is - // return. - repeated string collection_member_ids = 5; - - // The Global Trade Item Number (GTIN) of the product. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Corresponding properties: Google Merchant Center property - // [gtin](https://support.google.com/merchants/answer/6324461). - // Schema.org property - // [Product.isbn](https://schema.org/isbn), - // [Product.gtin8](https://schema.org/gtin8), - // [Product.gtin12](https://schema.org/gtin12), - // [Product.gtin13](https://schema.org/gtin13), or - // [Product.gtin14](https://schema.org/gtin14). - // - // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. - string gtin = 6; - - // Product categories. This field is repeated for supporting one product - // belonging to several parallel categories. Strongly recommended using the - // full path for better search / recommendation quality. - // - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // For example, if a shoes product belongs to both - // ["Shoes & Accessories" -> "Shoes"] and - // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be - // represented as: - // - // "categories": [ - // "Shoes & Accessories > Shoes", - // "Sports & Fitness > Athletic Clothing > Shoes" - // ] - // - // Must be set for [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product] otherwise an INVALID_ARGUMENT - // error is returned. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2.Product]. Empty values are not allowed. - // Each value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [google_product_category][mc_google_product_category]. Schema.org property - // [Product.category] (https://schema.org/category). - // - // [mc_google_product_category]: - // https://support.google.com/merchants/answer/6324436 - repeated string categories = 7; - - // Required. Product title. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [title](https://support.google.com/merchants/answer/6324415). Schema.org - // property [Product.name](https://schema.org/name). - string title = 8 [(google.api.field_behavior) = REQUIRED]; - - // The brands of the product. - // - // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded - // string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [brand](https://support.google.com/merchants/answer/6324351). Schema.org - // property [Product.brand](https://schema.org/brand). - repeated string brands = 9; - - // Product description. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [description](https://support.google.com/merchants/answer/6324468). - // Schema.org property [Product.description](https://schema.org/description). - string description = 10; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // - // For product prediction, this field is ignored and the model automatically - // detects the text language. The [Product][google.cloud.retail.v2.Product] - // can include text in different languages, but duplicating - // [Product][google.cloud.retail.v2.Product]s to provide text in multiple - // languages can result in degraded model performance. - // - // For product search this field is in use. It defaults to "en-US" if unset. - string language_code = 11; - - // Highly encouraged. Extra product attributes to be included. For example, - // for products, this could include the store name, vendor, style, color, etc. - // These are very strong signals for recommendation model, thus we highly - // recommend providing the attributes here. - // - // Features that can take on one of a limited number of possible values. Two - // types of features can be set are: - // - // Textual features. some examples would be the brand/maker of a product, or - // country of a customer. Numerical features. Some examples would be the - // height/weight of a product, or age of a customer. - // - // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, - // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} - // }`. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * Max entries count: 200. - // * The key must be a UTF-8 encoded string with a length limit of 128 - // characters. - // * For indexable attribute, the key must match the pattern: - // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or - // `KEY_1_LIKE_THIS`. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a non-empty UTF-8 encoded string with a - // length limit of 256 characters. - // * For number attributes, at most 400 values are allowed. - map attributes = 12; - - // Custom tags associated with the product. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2.Product]. This value must be a UTF-8 - // encoded string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This tag can be used for filtering recommendation results by passing the - // tag as part of the - // [PredictRequest.filter][google.cloud.retail.v2.PredictRequest.filter]. - // - // Corresponding properties: Google Merchant Center property - // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). - repeated string tags = 13; - - // Product price and cost information. - // - // Corresponding properties: Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 14; - - // The rating of this product. - Rating rating = 15; - - // The timestamp when this [Product][google.cloud.retail.v2.Product] becomes - // available for - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - google.protobuf.Timestamp available_time = 18; - - // The online availability of the [Product][google.cloud.retail.v2.Product]. - // Default to - // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK]. - // - // Corresponding properties: Google Merchant Center property - // [availability](https://support.google.com/merchants/answer/6324448). - // Schema.org property [Offer.availability](https://schema.org/availability). - Availability availability = 19; - - // The available quantity of the item. - google.protobuf.Int32Value available_quantity = 20; - - // Fulfillment information, such as the store IDs for in-store pickup or - // region IDs for different shipping methods. - // - // All the elements must have distinct - // [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type]. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated FulfillmentInfo fulfillment_info = 21; - - // Canonical URL directly linking to the product detail page. - // - // It is strongly recommended to provide a valid uri for the product, - // otherwise the service performance could be significantly degraded. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [link](https://support.google.com/merchants/answer/6324416). Schema.org - // property [Offer.url](https://schema.org/url). - string uri = 22; - - // Product images for the product. We highly recommend putting the main - // image first. - // - // A maximum of 300 images are allowed. - // - // Corresponding properties: Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - repeated Image images = 23; - - // The target group associated with a given audience (e.g. male, veterans, - // car owners, musicians, etc.) of the product. - Audience audience = 24; - - // The color of the product. - // - // Corresponding properties: Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - ColorInfo color_info = 25; - - // The size of the product. To represent different size systems or size types, - // consider using this format: [[[size_system:]size_type:]size_value]. - // - // For example, in "US:MENS:M", "US" represents size system; "MENS" represents - // size type; "M" represents size value. In "GIRLS:27", size system is empty; - // "GIRLS" represents size type; "27" represents size value. In "32 inches", - // both size system and size type are empty, while size value is "32 inches". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [size](https://support.google.com/merchants/answer/6324492), - // [size_type](https://support.google.com/merchants/answer/6324497), and - // [size_system](https://support.google.com/merchants/answer/6324502). - // Schema.org property [Product.size](https://schema.org/size). - repeated string sizes = 26; - - // The material of the product. For example, "leather", "wooden". - // - // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 200 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [material](https://support.google.com/merchants/answer/6324410). Schema.org - // property [Product.material](https://schema.org/material). - repeated string materials = 27; - - // The pattern or graphic print of the product. For example, "striped", "polka - // dot", "paisley". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org - // property [Product.pattern](https://schema.org/pattern). - repeated string patterns = 28; - - // The condition of the product. Strongly encouraged to use the standard - // values: "new", "refurbished", "used". - // - // A maximum of 1 value is allowed per - // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [condition](https://support.google.com/merchants/answer/6324469). - // Schema.org property - // [Offer.itemCondition](https://schema.org/itemCondition). - repeated string conditions = 29; - - // The promotions applied to the product. A maximum of 10 values are allowed - // per [Product][google.cloud.retail.v2.Product]. Only - // [Promotion.promotion_id][google.cloud.retail.v2.Promotion.promotion_id] - // will be used, other fields will be ignored if set. - repeated Promotion promotions = 34; - - // The timestamp when the product is published by the retailer for the first - // time, which indicates the freshness of the products. Note that this field - // is different from - // [available_time][google.cloud.retail.v2.Product.available_time], given it - // purely describes product freshness regardless of when it is available on - // search and recommendation. - google.protobuf.Timestamp publish_time = 33; - - // Indicates which fields in the [Product][google.cloud.retail.v2.Product]s - // are returned in [SearchResponse][google.cloud.retail.v2.SearchResponse]. - // - // Supported fields for all [type][google.cloud.retail.v2.Product.type]s: - // - // * [audience][google.cloud.retail.v2.Product.audience] - // * [availability][google.cloud.retail.v2.Product.availability] - // * [brands][google.cloud.retail.v2.Product.brands] - // * [color_info][google.cloud.retail.v2.Product.color_info] - // * [conditions][google.cloud.retail.v2.Product.conditions] - // * [gtin][google.cloud.retail.v2.Product.gtin] - // * [materials][google.cloud.retail.v2.Product.materials] - // * [name][google.cloud.retail.v2.Product.name] - // * [patterns][google.cloud.retail.v2.Product.patterns] - // * [price_info][google.cloud.retail.v2.Product.price_info] - // * [rating][google.cloud.retail.v2.Product.rating] - // * [sizes][google.cloud.retail.v2.Product.sizes] - // * [title][google.cloud.retail.v2.Product.title] - // * [uri][google.cloud.retail.v2.Product.uri] - // - // Supported fields only for - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]: - // - // * [categories][google.cloud.retail.v2.Product.categories] - // * [description][google.cloud.retail.v2.Product.description] - // * [images][google.cloud.retail.v2.Product.images] - // - // Supported fields only for - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]: - // - // * Only the first image in [images][google.cloud.retail.v2.Product.images] - // - // To mark [attributes][google.cloud.retail.v2.Product.attributes] as - // retrievable, include paths of the form "attributes.key" where "key" is the - // key of a custom attribute, as specified in - // [attributes][google.cloud.retail.v2.Product.attributes]. - // - // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], the - // following fields are always returned in - // [SearchResponse][google.cloud.retail.v2.SearchResponse] by default: - // - // * [name][google.cloud.retail.v2.Product.name] - // - // For [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT], the - // following fields are always returned in by default: - // - // * [name][google.cloud.retail.v2.Product.name] - // * [color_info][google.cloud.retail.v2.Product.color_info] - // - // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Note: Returning more fields in - // [SearchResponse][google.cloud.retail.v2.SearchResponse] may increase - // response payload size and serving latency. - google.protobuf.FieldMask retrievable_fields = 30; - - // Output only. Product variants grouped together on primary product which - // share similar product attributes. It's automatically grouped by - // [primary_product_id][google.cloud.retail.v2.Product.primary_product_id] for - // all the product variants. Only populated for - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. - // Do not set this field in API requests. - repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto deleted file mode 100644 index 71319834..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto +++ /dev/null @@ -1,822 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/import_config.proto"; -import "google/cloud/retail/v2/product.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for ingesting [Product][google.cloud.retail.v2.Product] information -// of the customer's website. -service ProductService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a [Product][google.cloud.retail.v2.Product]. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Gets a [Product][google.cloud.retail.v2.Product]. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Product][google.cloud.retail.v2.Product]s. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a [Product][google.cloud.retail.v2.Product]. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v2/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Deletes a [Product][google.cloud.retail.v2.Product]. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. - // - // Request processing may be synchronous. No partial updating is supported. - // Non-existing items are created. - // - // Note that it is possible for a subset of the - // [Product][google.cloud.retail.v2.Product]s to be successfully updated. - rpc ImportProducts(ImportProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.ImportProductsResponse" - metadata_type: "google.cloud.retail.v2.ImportMetadata" - }; - } - - // Updates inventory information for a - // [Product][google.cloud.retail.v2.Product] while respecting the last update - // timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, updates are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // When inventory is updated with - // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and - // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the - // specified inventory field value(s) will overwrite any existing value(s) - // while ignoring the last update time for this field. Furthermore, the last - // update time for the specified inventory fields will be overwritten to the - // time of the - // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or - // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] - // request. - // - // If no inventory fields are set in - // [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], - // then any pre-existing inventory information for this product will be used. - // - // If no inventory fields are set in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], - // then any existing inventory information will be preserved. - // - // Pre-existing inventory information can only be updated with - // [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], - // [AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], - // and - // [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" - body: "*" - }; - option (google.api.method_signature) = "inventory,set_mask"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.SetInventoryResponse" - metadata_type: "google.cloud.retail.v2.SetInventoryMetadata" - }; - } - - // Incrementally adds place IDs to - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the added place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.AddFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2.AddFulfillmentPlacesMetadata" - }; - } - - // Incrementally removes place IDs from a - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the removed place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata" - }; - } - - // Updates local inventory information for a - // [Product][google.cloud.retail.v2.Product] at a list of places, while - // respecting the last update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2.Product] to exist before updating - // inventory information. If the request is valid, the update will be enqueued - // and processed downstream. As a consequence, when a response is returned, - // updates are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // Local inventory information can only be modified using this method. - // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and - // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no - // effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddLocalInventories(AddLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.AddLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2.AddLocalInventoriesMetadata" - }; - } - - // Remove local inventory information for a - // [Product][google.cloud.retail.v2.Product] at a list of places at a removal - // timestamp. - // - // This process is asynchronous. If the request is valid, the removal will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, removals are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // Local inventory information can only be removed using this method. - // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and - // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no - // effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.RemoveLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2.RemoveLocalInventoriesMetadata" - }; - } -} - -// Request message for [CreateProduct][] method. -message CreateProductRequest { - // Required. The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Required. The [Product][google.cloud.retail.v2.Product] to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the [Product][google.cloud.retail.v2.Product], - // which will become the final component of the - // [Product.name][google.cloud.retail.v2.Product.name]. - // - // If the caller does not have permission to create the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // This field must be unique among all - // [Product][google.cloud.retail.v2.Product]s with the same - // [parent][google.cloud.retail.v2.CreateProductRequest.parent]. Otherwise, an - // ALREADY_EXISTS error is returned. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string product_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [GetProduct][] method. -message GetProductRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // If the requested [Product][google.cloud.retail.v2.Product] does not exist, - // a NOT_FOUND error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for [UpdateProduct][] method. -message UpdateProductRequest { - // Required. The product to update/create. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2.Product] to update does not exist - // and - // [allow_missing][google.cloud.retail.v2.UpdateProductRequest.allow_missing] - // is not set, a NOT_FOUND error is returned. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Product][google.cloud.retail.v2.Product] to update. The immutable and - // output only fields are NOT supported. If not set, all supported fields (the - // fields that are neither immutable nor output only) are updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, a new [Product][google.cloud.retail.v2.Product] will be created. In - // this situation, `update_mask` is ignored. - bool allow_missing = 3; -} - -// Request message for [DeleteProduct][] method. -message DeleteProductRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to delete the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2.Product] to delete does not exist, - // a NOT_FOUND error is returned. - // - // The [Product][google.cloud.retail.v2.Product] to delete can neither be a - // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2.Product] member nor a - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product] with more than one - // [variants][google.cloud.retail.v2.Product.Type.VARIANT]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // All inventory information for the named - // [Product][google.cloud.retail.v2.Product] will be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for -// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] -// method. -message ListProductsRequest { - // Required. The parent branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use - // `default_branch` as the branch ID, to list products under the default - // branch. - // - // If the caller does not have permission to list - // [Product][google.cloud.retail.v2.Product]s under this branch, regardless of - // whether or not this branch exists, a PERMISSION_DENIED error is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If - // unspecified, defaults to 100. The maximum allowed value is 1000. Values - // above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT error is returned. - int32 page_size = 2; - - // A page token - // [ListProductsResponse.next_page_token][google.cloud.retail.v2.ListProductsResponse.next_page_token], - // received from a previous - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; - - // A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2.ListProductsRequest.filter] is unset. - // * List [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s sharing the same - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]. For example: - // `primary_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2.Product]s bundled in a - // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2.Product]. - // For example: - // `collection_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2.Product]s with a partibular type. - // For example: - // `type = "PRIMARY"` - // `type = "VARIANT"` - // `type = "COLLECTION"` - // - // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - // - // If the specified - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product] or - // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2.Product] does not exist, a NOT_FOUND error - // is returned. - string filter = 4; - - // The fields of [Product][google.cloud.retail.v2.Product] to return in the - // responses. If not set or empty, the following fields are returned: - // - // * [Product.name][google.cloud.retail.v2.Product.name] - // * [Product.id][google.cloud.retail.v2.Product.id] - // * [Product.title][google.cloud.retail.v2.Product.title] - // * [Product.uri][google.cloud.retail.v2.Product.uri] - // * [Product.images][google.cloud.retail.v2.Product.images] - // * [Product.price_info][google.cloud.retail.v2.Product.price_info] - // * [Product.brands][google.cloud.retail.v2.Product.brands] - // - // If "*" is provided, all fields are returned. - // [Product.name][google.cloud.retail.v2.Product.name] is always returned no - // matter what mask is set. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask read_mask = 5; -} - -// Response message for -// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] -// method. -message ListProductsResponse { - // The [Product][google.cloud.retail.v2.Product]s. - repeated Product products = 1; - - // A token that can be sent as - // [ListProductsRequest.page_token][google.cloud.retail.v2.ListProductsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request message for [SetInventory][] method. -message SetInventoryRequest { - // Required. The inventory information to update. The allowable fields to - // update are: - // * [Product.price_info][google.cloud.retail.v2.Product.price_info] - // * [Product.availability][google.cloud.retail.v2.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] - // The updated inventory fields must be specified in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask]. - // - // If [SetInventoryRequest.inventory.name][] is empty or invalid, an - // INVALID_ARGUMENT error is returned. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2.Product] named in - // [Product.name][google.cloud.retail.v2.Product.name], regardless of whether - // or not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2.Product] to update does not have - // existing inventory information, the provided inventory information will be - // inserted. - // - // If the [Product][google.cloud.retail.v2.Product] to update has existing - // inventory information, the provided inventory information will be merged - // while respecting the last update time for each inventory field, using the - // provided or default value for - // [SetInventoryRequest.set_time][google.cloud.retail.v2.SetInventoryRequest.set_time]. - // - // The caller can replace place IDs for a subset of fulfillment types in the - // following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types and corresponding place IDs - // to update in [SetInventoryRequest.inventory.fulfillment_info][] - // - // The caller can clear all place IDs from a subset of fulfillment types in - // the following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types to clear in - // [SetInventoryRequest.inventory.fulfillment_info][] - // * Checks that only the desired fulfillment info types have empty - // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] - // - // The last update time is recorded for the following inventory fields: - // * [Product.price_info][google.cloud.retail.v2.Product.price_info] - // * [Product.availability][google.cloud.retail.v2.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] - // - // If a full overwrite of inventory information while ignoring timestamps is - // needed, [UpdateProduct][] should be invoked instead. - Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided - // [Product][google.cloud.retail.v2.Product] to update. - // - // At least one field must be provided. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask set_mask = 2; - - // The time when the request is issued, used to prevent - // out-of-order updates on inventory fields with the last update time - // recorded. If not provided, the internal system time will be used. - google.protobuf.Timestamp set_time = 3; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] with name - // [Product.name][google.cloud.retail.v2.Product.name] is not found, the - // inventory update will still be processed and retained for at most 1 day - // until the [Product][google.cloud.retail.v2.Product] is created. If set to - // false, a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 4; -} - -// Metadata related to the progress of the SetInventory operation. -// Currently empty because there is no meaningful metadata populated from the -// [SetInventory][] method. -message SetInventoryMetadata {} - -// Response of the SetInventoryRequest. Currently empty because -// there is no meaningful response populated from the [SetInventory][] -// method. -message SetInventoryResponse {} - -// Request message for [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type], such as - // the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery" to be added for this - // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type]. Duplicate - // IDs will be automatically ignored. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // If the total number of place IDs exceeds 2000 for this - // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type] after - // adding, then the update will be rejected. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, the fulfillment information will still be processed and retained for - // at most 1 day and processed once the - // [Product][google.cloud.retail.v2.Product] is created. If set to false, a - // NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the AddFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesMetadata {} - -// Response of the AddFulfillmentPlacesRequest. Currently empty because -// there is no meaningful response populated from the [AddFulfillmentPlaces][] -// method. -message AddFulfillmentPlacesResponse {} - -// Request message for [AddLocalInventories][] method. -message AddLocalInventoriesRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of inventory information at difference places. Each place - // is identified by its place ID. At most 3000 inventories are allowed per - // request. - repeated LocalInventory local_inventories = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided list of - // [LocalInventory][google.cloud.retail.v2.LocalInventory] to update. The - // field is updated to the provided value. - // - // If a field is set while the place does not have a previous local inventory, - // the local inventory at that store is created. - // - // If a field is set while the value of that field is not provided, the - // original field value, if it exists, is deleted. - // - // If the mask is not set or set with empty paths, all inventory fields will - // be updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask add_mask = 4; - - // The time when the inventory updates are issued. Used to prevent - // out-of-order updates on local inventory fields. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, the local inventory will still be processed and retained for at most - // 1 day and processed once the [Product][google.cloud.retail.v2.Product] is - // created. If set to false, a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 6; -} - -// Metadata related to the progress of the AddLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddLocalInventories][] method. -message AddLocalInventoriesMetadata {} - -// Response of the [AddLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [AddLocalInventories][] -// method. -message AddLocalInventoriesResponse {} - -// Request message for [RemoveLocalInventories][] method. -message RemoveLocalInventoriesRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of place IDs to have their inventory deleted. - // At most 3000 place IDs are allowed per request. - repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; - - // The time when the inventory deletions are issued. Used to prevent - // out-of-order updates and deletions on local inventory fields. If not - // provided, the internal system time will be used. - google.protobuf.Timestamp remove_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, the local inventory removal request will still be processed and - // retained for at most 1 day and processed once the - // [Product][google.cloud.retail.v2.Product] is created. If set to false, a - // NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 3; -} - -// Metadata related to the progress of the RemoveLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveLocalInventories][] method. -message RemoveLocalInventoriesMetadata {} - -// Response of the [RemoveLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [RemoveLocalInventories][] -// method. -message RemoveLocalInventoriesResponse {} - -// Request message for [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type], such as - // the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery", to be removed for this - // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type]. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp remove_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, the fulfillment information will still be processed and retained for - // at most 1 day and processed once the - // [Product][google.cloud.retail.v2.Product] is created. If set to false, a - // NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the RemoveFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesMetadata {} - -// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there -// is no meaningful response populated from the [RemoveFulfillmentPlaces][] -// method. -message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto deleted file mode 100644 index 9ba32347..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "PromotionProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Promotion information. -message Promotion { - // ID of the promotion. For example, "free gift". - // - // The value must be a UTF-8 encoded string with a length limit of 128 - // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, - // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Google Merchant Center property - // [promotion](https://support.google.com/merchants/answer/7050148). - string promotion_id = 1; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto deleted file mode 100644 index 6c8d54c7..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "PurgeConfigProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Metadata related to the progress of the Purge operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeMetadata {} - -// Request message for PurgeUserEvents method. -message PurgeUserEventsRequest { - // Required. The resource name of the catalog under which the events are - // created. The format is - // `projects/${projectId}/locations/global/catalogs/${catalogId}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The filter string to specify the events to be deleted with a - // length limit of 5,000 characters. Empty string filter is not allowed. The - // eligible fields for filtering are: - // - // * `eventType`: Double quoted - // [UserEvent.event_type][google.cloud.retail.v2.UserEvent.event_type] string. - // * `eventTime`: in ISO 8601 "zulu" format. - // * `visitorId`: Double quoted string. Specifying this will delete all - // events associated with a visitor. - // * `userId`: Double quoted string. Specifying this will delete all events - // associated with a user. - // - // Examples: - // - // * Deleting all events in a time range: - // `eventTime > "2012-04-23T18:25:43.511Z" - // eventTime < "2012-04-23T18:30:43.511Z"` - // * Deleting specific eventType in time range: - // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - // * Deleting all events for a specific visitor: - // `visitorId = "visitor1024"` - // - // The filtering fields are assumed to have an implicit AND. - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually perform the purge. - // If `force` is set to false, the method will return the expected purge count - // without deleting any user events. - bool force = 3; -} - -// Response of the PurgeUserEventsRequest. If the long running operation is -// successfully done, then this message is returned by the -// google.longrunning.Operations.response field. -message PurgeUserEventsResponse { - // The total count of events purged as a result of the operation. - int64 purged_events_count = 1; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto deleted file mode 100644 index ec8750ae..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto +++ /dev/null @@ -1,786 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/product.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "SearchServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for search. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service SearchService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Performs a search. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc Search(SearchRequest) returns (SearchResponse) { - option (google.api.http) = { - post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" - body: "*" - }; - } -} - -// Request message for -// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. -message SearchRequest { - // A facet specification to perform faceted search. - message FacetSpec { - // Specifies how a facet is computed. - message FacetKey { - // Required. Supported textual and numerical facet keys in - // [Product][google.cloud.retail.v2.Product] object, over which the facet - // values are computed. Facet key is case-sensitive. - // - // Allowed facet keys when - // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] - // is not specified: - // - // * textual_field = - // * "brands" - // * "categories" - // * "genders" - // * "ageGroups" - // * "availability" - // * "colorFamilies" - // * "colors" - // * "sizes" - // * "materials" - // * "patterns" - // * "conditions" - // * "attributes.key" - // * "pickupInStore" - // * "shipToStore" - // * "sameDayDelivery" - // * "nextDayDelivery" - // * "customFulfillment1" - // * "customFulfillment2" - // * "customFulfillment3" - // * "customFulfillment4" - // * "customFulfillment5" - // * "inventory(place_id,attributes.key)" - // - // * numerical_field = - // * "price" - // * "discount" - // * "rating" - // * "ratingCount" - // * "attributes.key" - // * "inventory(place_id,price)" - // * "inventory(place_id,original_price)" - // * "inventory(place_id,attributes.key)" - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Set only if values should be bucketized into intervals. Must be set - // for facets with numerical values. Must not be set for facet with text - // values. Maximum number of intervals is 30. - repeated Interval intervals = 2; - - // Only get facet for the given restricted values. For example, when using - // "pickupInStore" as key and set restricted values to - // ["store123", "store456"], only facets for "store123" and "store456" are - // returned. Only supported on textual fields and fulfillments. - // Maximum is 20. - // - // Must be set for the fulfillment facet keys: - // - // * pickupInStore - // - // * shipToStore - // - // * sameDayDelivery - // - // * nextDayDelivery - // - // * customFulfillment1 - // - // * customFulfillment2 - // - // * customFulfillment3 - // - // * customFulfillment4 - // - // * customFulfillment5 - repeated string restricted_values = 3; - - // Only get facet values that start with the given string prefix. For - // example, suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the - // "categories" facet will give only "Women > Shoe" and "Women > Dress". - // Only supported on textual fields. Maximum is 10. - repeated string prefixes = 8; - - // Only get facet values that contains the given strings. For example, - // suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the - // "categories" facet will give only "Women > Shoe" and "Men > Shoe". - // Only supported on textual fields. Maximum is 10. - repeated string contains = 9; - - // The order in which [Facet.values][] are returned. - // - // Allowed values are: - // - // * "count desc", which means order by [Facet.FacetValue.count][] - // descending. - // - // * "value desc", which means order by [Facet.FacetValue.value][] - // descending. - // Only applies to textual facets. - // - // If not set, textual values are sorted in [natural - // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical - // intervals are sorted in the order given by - // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.intervals]; - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // are sorted in the order given by - // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.restricted_values]. - string order_by = 4; - - // The query that is used to compute facet for the given facet key. - // When provided, it will override the default behavior of facet - // computation. The query syntax is the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for - // detail syntax and limitations. Notice that there is no limitation on - // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] - // when query is specified. - // - // In the response, [FacetValue.value][] will be always "1" and - // [FacetValue.count][] will be the number of results that matches the - // query. - // - // For example, you can set a customized facet for "shipToStore", - // where - // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] - // is "customizedShipToStore", and - // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] - // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". - // Then the facet will count the products that are both in stock and ship - // to store "123". - string query = 5; - } - - // Required. The facet key specification. - FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum of facet values that should be returned for this facet. If - // unspecified, defaults to 20. The maximum allowed value is 300. Values - // above 300 will be coerced to 300. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 limit = 2; - - // List of keys to exclude when faceting. - // - // By default, - // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] - // is not excluded from the filter unless it is listed in this field. - // - // For example, suppose there are 100 products with color facet "Red" and - // 200 products with color facet "Blue". A query containing the filter - // "colorFamilies:ANY("Red")" and have "colorFamilies" as - // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] - // will by default return the "Red" with count 100. - // - // If this field contains "colorFamilies", then the query returns both the - // "Red" with count 100 and "Blue" with count 200, because the - // "colorFamilies" key is now excluded from the filter. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated string excluded_filter_keys = 3; - - // Enables dynamic position for this facet. If set to true, the position of - // this facet among all facets in the response is determined by Google - // Retail Search. It will be ordered together with dynamic facets if dynamic - // facets is enabled. If set to false, the position of this facet in the - // response will be the same as in the request, and it will be ranked before - // the facets with dynamic position enable and all dynamic facets. - // - // For example, you may always want to have rating facet returned in - // the response, but it's not necessarily to always display the rating facet - // at the top. In that case, you can set enable_dynamic_position to true so - // that the position of rating facet in response will be determined by - // Google Retail Search. - // - // Another example, assuming you have the following facets in the request: - // - // * "rating", enable_dynamic_position = true - // - // * "price", enable_dynamic_position = false - // - // * "brands", enable_dynamic_position = false - // - // And also you have a dynamic facets enable, which will generate a facet - // 'gender'. Then the final order of the facets in the response can be - // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", - // "rating") depends on how Google Retail Search orders "gender" and - // "rating" facets. However, notice that "price" and "brands" will always be - // ranked at 1st and 2nd position since their enable_dynamic_position are - // false. - bool enable_dynamic_position = 4; - } - - // The specifications of dynamically generated facets. - message DynamicFacetSpec { - // Enum to control DynamicFacet mode - enum Mode { - // Default value. - MODE_UNSPECIFIED = 0; - - // Disable Dynamic Facet. - DISABLED = 1; - - // Automatic mode built by Google Retail Search. - ENABLED = 2; - } - - // Mode of the DynamicFacet feature. - // Defaults to - // [Mode.DISABLED][google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode.DISABLED] - // if it's unset. - Mode mode = 1; - } - - // Boost specification to boost certain items. - message BoostSpec { - // Boost applies to products which match a condition. - message ConditionBoostSpec { - // An expression which specifies a boost condition. The syntax and - // supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for - // detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue": - // * (id: ANY("product_1", "product_2")) AND (colorFamilies: - // ANY("Red","Blue")) - string condition = 1; - - // Strength of the condition boost, which should be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 2; - } - - // Condition boost specifications. If a product matches multiple conditions - // in the specifictions, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 10. - repeated ConditionBoostSpec condition_boost_specs = 1; - - // Whether to skip boostspec validation. If this field is set to true, - // invalid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] - // will be ignored and valid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] - // will still be applied. - optional bool skip_boost_spec_validation = 2; - } - - // Specification to determine under which conditions query expansion should - // occur. - message QueryExpansionSpec { - // Enum describing under which condition query expansion should occur. - enum Condition { - // Unspecified query expansion condition. This defaults to - // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - CONDITION_UNSPECIFIED = 0; - - // Disabled query expansion. Only the exact search query is used, even if - // [SearchResponse.total_size][google.cloud.retail.v2.SearchResponse.total_size] - // is zero. - DISABLED = 1; - - // Automatic query expansion built by Google Retail Search. - AUTO = 3; - } - - // The condition under which query expansion should occur. Default to - // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - Condition condition = 1; - - // Whether to pin unexpanded results. If this field is set to true, - // unexpanded products are always at the top of the search results, followed - // by the expanded results. - bool pin_unexpanded_results = 2; - } - - // The specification for personalization. - message PersonalizationSpec { - // The personalization mode of each search request. - enum Mode { - // Default value. Defaults to - // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Let CRS decide whether to use personalization. - AUTO = 1; - - // Disable personalization. - DISABLED = 2; - } - - // Defaults to - // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. - Mode mode = 1; - } - - // The search mode of each search request. - enum SearchMode { - // Default value. In this case both product search and faceted search will - // be performed. Both [SearchResponse.SearchResult] and - // [SearchResponse.Facet] will be returned. - SEARCH_MODE_UNSPECIFIED = 0; - - // Only product search will be performed. The faceted search will be - // disabled. - // - // Only [SearchResponse.SearchResult] will be returned. - // [SearchResponse.Facet] will not be returned, even if - // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] - // or - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] - // is set. - PRODUCT_SEARCH_ONLY = 1; - - // Only faceted search will be performed. The product search will be - // disabled. - // - // When in this mode, one or both of [SearchRequest.facet_spec][] and - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] - // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only - // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] - // will not be returned. - FACETED_SEARCH_ONLY = 2; - } - - // Required. The resource name of the search engine placement, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` - // This field is used to identify the serving configuration name and the set - // of models that will be used to make the search. - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. - // - // Use "default_branch" as the branch ID or leave this field empty, to search - // products under the default branch. - string branch = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Raw search query. - string query = 3; - - // Required. A unique identifier for tracking visitors. For example, this - // could be implemented with an HTTP cookie, which should be able to uniquely - // identify a visitor on a single device. This unique identifier should not - // change if the visitor logs in or out of the website. - // - // This should be the same identifier as - // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id]. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; - - // User information. - UserInfo user_info = 5; - - // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If - // unspecified, defaults to a reasonable value. The maximum allowed value is - // 120. Values above 120 will be coerced to 120. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 7; - - // A page token - // [SearchResponse.next_page_token][google.cloud.retail.v2.SearchResponse.next_page_token], - // received from a previous - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] must - // match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - // error is returned. - string page_token = 8; - - // A 0-indexed integer that specifies the current offset (that is, starting - // result location, amongst the [Product][google.cloud.retail.v2.Product]s - // deemed by the API as relevant) in search results. This field is only - // considered if [page_token][google.cloud.retail.v2.SearchRequest.page_token] - // is unset. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 offset = 9; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. Filter - // expression is case-sensitive. See more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string filter = 10; - - // The default filter that is applied when a user performs a search without - // checking any filters on the search page. - // - // The filter applied to every search request when quality improvement such as - // query expansion is needed. For example, if a query does not have enough - // results, an expanded query with - // [SearchRequest.canonical_filter][google.cloud.retail.v2.SearchRequest.canonical_filter] - // will be returned as a supplement of the original query. This field is - // strongly recommended to achieve high search quality. - // - // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for - // more details about filter syntax. - string canonical_filter = 28; - - // The order in which products are returned. Products can be ordered by - // a field in an [Product][google.cloud.retail.v2.Product] object. Leave it - // unset if ordered by relevance. OrderBy expression is case-sensitive. See - // more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#order). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string order_by = 11; - - // Facet specifications for faceted search. If empty, no facets are returned. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated FacetSpec facet_specs = 12; - - // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - // to enable dynamic facets. Do not set this field. - // - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; - - // Boost specification to boost certain products. See more details at this - // [user guide](https://cloud.google.com/retail/docs/boosting). - // - // Notice that if both [ServingConfig.boost_control_ids][] and - // [SearchRequest.boost_spec] are set, the boost conditions from both places - // are evaluated. If a search request matches multiple boost conditions, - // the final boost score is equal to the sum of the boost scores from all - // matched boost conditions. - BoostSpec boost_spec = 13; - - // The query expansion specification that specifies the conditions under which - // query expansion will occur. See more details at this [user - // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - QueryExpansionSpec query_expansion_spec = 14; - - // The keys to fetch and rollup the matching - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s attributes, - // [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo] or - // [LocalInventory][google.cloud.retail.v2.LocalInventory]s attributes. The - // attributes from all the matching - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s or - // [LocalInventory][google.cloud.retail.v2.LocalInventory]s are merged and - // de-duplicated. Notice that rollup attributes will lead to extra query - // latency. Maximum number of keys is 30. - // - // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], a - // fulfillment type and a fulfillment ID must be provided in the format of - // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - // "pickupInStore" is fulfillment type and "store123" is the store ID. - // - // Supported keys are: - // - // * colorFamilies - // * price - // * originalPrice - // * discount - // * variantId - // * inventory(place_id,price) - // * inventory(place_id,original_price) - // * inventory(place_id,attributes.key), where key is any key in the - // [Product.inventories.attributes][] map. - // * attributes.key, where key is any key in the - // [Product.attributes][google.cloud.retail.v2.Product.attributes] map. - // * pickupInStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "pickup-in-store". - // * shipToStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "ship-to-store". - // * sameDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "same-day-delivery". - // * nextDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "next-day-delivery". - // * customFulfillment1.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-1". - // * customFulfillment2.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-2". - // * customFulfillment3.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-3". - // * customFulfillment4.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-4". - // * customFulfillment5.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-5". - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - repeated string variant_rollup_keys = 17; - - // The categories associated with a category page. Required for category - // navigation queries to achieve good search quality. The format should be - // the same as - // [UserEvent.page_categories][google.cloud.retail.v2.UserEvent.page_categories]; - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - repeated string page_categories = 23; - - // The search mode of the search request. If not specified, a single search - // request triggers both product search and faceted search. - SearchMode search_mode = 31; - - // The specification for personalization. - PersonalizationSpec personalization_spec = 32; -} - -// Response message for -// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. -message SearchResponse { - // Represents the search results. - message SearchResult { - // [Product.id][google.cloud.retail.v2.Product.id] of the searched - // [Product][google.cloud.retail.v2.Product]. - string id = 1; - - // The product data snippet in the search response. Only - // [Product.name][google.cloud.retail.v2.Product.name] is guaranteed to be - // populated. - // - // [Product.variants][google.cloud.retail.v2.Product.variants] contains the - // product variants that match the search query. If there are multiple - // product variants matching the query, top 5 most relevant product variants - // are returned and ordered by relevancy. - // - // If relevancy can be deternmined, use - // [matching_variant_fields][google.cloud.retail.v2.SearchResponse.SearchResult.matching_variant_fields] - // to look up matched product variants fields. If relevancy cannot be - // determined, e.g. when searching "shoe" all products in a shoe product can - // be a match, 5 product variants are returned but order is meaningless. - Product product = 2; - - // The count of matched - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s. - int32 matching_variant_count = 3; - - // If a [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] matches the search query, this - // map indicates which [Product][google.cloud.retail.v2.Product] fields are - // matched. The key is the - // [Product.name][google.cloud.retail.v2.Product.name], the value is a field - // mask of the matched [Product][google.cloud.retail.v2.Product] fields. If - // matched attributes cannot be determined, this map will be empty. - // - // For example, a key "sku1" with field mask - // "products.color_info" indicates there is a match between - // "sku1" [ColorInfo][google.cloud.retail.v2.ColorInfo] and the query. - map matching_variant_fields = 4; - - // The rollup matching - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] attributes. The key is one of - // the - // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2.SearchRequest.variant_rollup_keys]. - // The values are the merged and de-duplicated - // [Product][google.cloud.retail.v2.Product] attributes. Notice that the - // rollup values are respect filter. For example, when filtering by - // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is - // returned. - // - // For textual and numerical attributes, the rollup values is a list of - // string or double values with type - // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if - // there are two variants with colors "red" and "blue", the rollup values - // are - // - // { key: "colorFamilies" - // value { - // list_value { - // values { string_value: "red" } - // values { string_value: "blue" } - // } - // } - // } - // - // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], the rollup - // values is a double value with type - // [google.protobuf.Value][google.protobuf.Value]. For example, - // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there - // are 10 variants in this product are available in the store "store1". - map variant_rollup_values = 5; - } - - // A facet result. - message Facet { - // A facet value which contains value names and their count. - message FacetValue { - // A facet value which contains values. - oneof facet_value { - // Text value of a facet, such as "Black" for facet "colorFamilies". - string value = 1; - - // Interval value for a facet, such as [10, 20) for facet "price". - Interval interval = 2; - } - - // Number of items that have this facet value. - int64 count = 3; - } - - // The key for this facet. E.g., "colorFamilies" or "price" or - // "attributes.attr1". - string key = 1; - - // The facet values for this field. - repeated FacetValue values = 2; - - // Whether the facet is dynamically generated. - bool dynamic_facet = 3; - } - - // Information describing query expansion including whether expansion has - // occurred. - message QueryExpansionInfo { - // Bool describing whether query expansion has occurred. - bool expanded_query = 1; - - // Number of pinned results. This field will only be set when expansion - // happens and - // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] - // is set to true. - int64 pinned_result_count = 2; - } - - // A list of matched items. The order represents the ranking. - repeated SearchResult results = 1; - - // Results of facets requested by user. - repeated Facet facets = 2; - - // The estimated total count of matched items irrespective of pagination. The - // count of [results][google.cloud.retail.v2.SearchResponse.results] returned - // by pagination may be less than the - // [total_size][google.cloud.retail.v2.SearchResponse.total_size] that - // matches. - int32 total_size = 3; - - // If spell correction applies, the corrected query. Otherwise, empty. - string corrected_query = 4; - - // A unique search token. This should be included in the - // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this - // search, which enables accurate attribution of search model performance. - string attribution_token = 5; - - // A token that can be sent as - // [SearchRequest.page_token][google.cloud.retail.v2.SearchRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 6; - - // Query expansion information for the returned results. - QueryExpansionInfo query_expansion_info = 7; - - // The URI of a customer-defined redirect page. If redirect action is - // triggered, no search will be performed, and only - // [redirect_uri][google.cloud.retail.v2.SearchResponse.redirect_uri] and - // [attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] - // will be set in the response. - string redirect_uri = 10; - - // The fully qualified resource name of applied - // [controls](https://cloud.google.com/retail/docs/serving-control-rules). - repeated string applied_controls = 12; - - // The invalid - // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] - // that are not applied during serving. - repeated SearchRequest.BoostSpec.ConditionBoostSpec - invalid_condition_boost_specs = 14; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto deleted file mode 100644 index 8e21f8aa..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto +++ /dev/null @@ -1,340 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/product.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// UserEvent captures all metadata information Retail API needs to know about -// how end users interact with customers' website. -message UserEvent { - // Required. User event type. Allowed values are: - // - // * `add-to-cart`: Products being added to cart. - // * `category-page-view`: Special pages such as sale or promotion pages - // viewed. - // * `detail-page-view`: Products detail page viewed. - // * `home-page-view`: Homepage viewed. - // * `promotion-offered`: Promotion is offered to a user. - // * `promotion-not-offered`: Promotion is not offered to a user. - // * `purchase-complete`: User finishing a purchase. - // * `search`: Product search. - // * `shopping-cart-page-view`: User viewing a shopping cart. - string event_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A unique identifier for tracking visitors. - // - // For example, this could be implemented with an HTTP cookie, which should be - // able to uniquely identify a visitor on a single device. This unique - // identifier should not change if the visitor log in/out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // The field should not contain PII or user-data. We recommend to use Google - // Analystics [Client - // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) - // for this field. - string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // A unique identifier for tracking a visitor session with a length limit of - // 128 bytes. A session is an aggregation of an end user behavior in a time - // span. - // - // A general guideline to populate the sesion_id: - // 1. If user has no activity for 30 min, a new session_id should be assigned. - // 2. The session_id should be unique across users, suggest use uuid or add - // visitor_id as prefix. - string session_id = 21; - - // Only required for - // [UserEventService.ImportUserEvents][google.cloud.retail.v2.UserEventService.ImportUserEvents] - // method. Timestamp of when the user event happened. - google.protobuf.Timestamp event_time = 3; - - // A list of identifiers for the independent experiment groups this user event - // belongs to. This is used to distinguish between user events associated with - // different experiment setups (e.g. using Retail API, using different - // recommendation models). - repeated string experiment_ids = 4; - - // Highly recommended for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. - // This field enables accurate attribution of recommendation model - // performance. - // - // The value must be a valid - // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] - // for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. - // The value must be a valid - // [SearchResponse.attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] - // for user events that are the result of - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - // - // This token enables us to accurately attribute page view or purchase back to - // the event and the particular predict response containing this - // clicked/purchased product. If user clicks on product K in the - // recommendation results, pass - // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] - // as a URL parameter to product K's page. When recording events on product - // K's page, log the - // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] - // to this field. - string attribution_token = 5; - - // The main product details related to the event. - // - // This field is required for the following event types: - // - // * `add-to-cart` - // * `detail-page-view` - // * `purchase-complete` - // * `search` - // - // In a `search` event, this field represents the products returned to the end - // user on the current page (the end user may have not finished browsing the - // whole page yet). When a new page is returned to the end user, after - // pagination/filtering/ordering even for the same query, a new `search` event - // with different - // [product_details][google.cloud.retail.v2.UserEvent.product_details] is - // desired. The end user may have not finished browsing the whole page yet. - repeated ProductDetail product_details = 6; - - // The main auto-completion details related to the event. - // - // This field should be set for `search` event when autocomplete function is - // enabled and the user clicks a suggestion for search. - CompletionDetail completion_detail = 22; - - // Extra user event features to include in the recommendation model. - // - // If you provide custom attributes for ingested user events, also include - // them in the user events that you associate with prediction requests. Custom - // attribute formatting must be consistent between imported events and events - // provided with prediction requests. This lets the Retail API use - // those custom attributes when training models and serving predictions, which - // helps improve recommendation quality. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * The key must be a UTF-8 encoded string with a length limit of 5,000 - // characters. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 256 characters. - // * For number attributes, at most 400 values are allowed. - // - // For product recommendations, an example of extra user information is - // traffic_channel, which is how a user arrives at the site. Users can arrive - // at the site by coming to the site directly, coming through Google - // search, or in other ways. - map attributes = 7; - - // The ID or name of the associated shopping cart. This ID is used - // to associate multiple items added or present in the cart before purchase. - // - // This can only be set for `add-to-cart`, `purchase-complete`, or - // `shopping-cart-page-view` events. - string cart_id = 8; - - // A transaction represents the entire purchase transaction. - // - // Required for `purchase-complete` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - PurchaseTransaction purchase_transaction = 9; - - // The user's search query. - // - // See [SearchRequest.query][google.cloud.retail.v2.SearchRequest.query] for - // definition. - // - // The value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // At least one of - // [search_query][google.cloud.retail.v2.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - string search_query = 10; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. - // - // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for - // definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string filter = 16; - - // The order in which products are returned. - // - // See [SearchRequest.order_by][google.cloud.retail.v2.SearchRequest.order_by] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string order_by = 17; - - // An integer that specifies the current offset for pagination (the 0-indexed - // starting location, amongst the products deemed by the API as relevant). - // - // See [SearchRequest.offset][google.cloud.retail.v2.SearchRequest.offset] for - // definition. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - int32 offset = 18; - - // The categories associated with a category page. - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - // - // Required for `category-page-view` events. At least one of - // [search_query][google.cloud.retail.v2.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated string page_categories = 11; - - // User information. - UserInfo user_info = 12; - - // Complete URL (window.location.href) of the user's current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. Maximum length 5,000 - // characters. - string uri = 13; - - // The referrer URL of the current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string referrer_uri = 14; - - // A unique ID of a web page view. - // - // This should be kept the same for all user events triggered from the same - // pageview. For example, an item detail page view could trigger multiple - // events as the user is browsing the page. The `pageViewId` property should - // be kept the same for all these events so that they can be grouped together - // properly. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string page_view_id = 15; -} - -// Detailed product information associated with a user event. -message ProductDetail { - // Required. [Product][google.cloud.retail.v2.Product] information. - // - // Required field(s): - // - // * [Product.id][google.cloud.retail.v2.Product.id] - // - // Optional override field(s): - // - // * [Product.price_info][google.cloud.retail.v2.Product.price_info] - // - // If any supported optional fields are provided, we will treat them as a full - // override when looking up product information from the catalog. Thus, it is - // important to ensure that the overriding fields are accurate and - // complete. - // - // All other product fields are ignored and instead populated via catalog - // lookup after event ingestion. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Quantity of the product associated with the user event. - // - // For example, this field will be 2 if two products are added to the shopping - // cart for `purchase-complete` event. Required for `add-to-cart` and - // `purchase-complete` event types. - google.protobuf.Int32Value quantity = 2; -} - -// Detailed completion information including completion attribution token and -// clicked completion info. -message CompletionDetail { - // Completion attribution token in - // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2.CompleteQueryResponse.attribution_token]. - string completion_attribution_token = 1; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion]. - string selected_suggestion = 2; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion] - // position, starting from 0. - int32 selected_position = 3; -} - -// A transaction represents the entire purchase transaction. -message PurchaseTransaction { - // The transaction ID with a length limit of 128 characters. - string id = 1; - - // Required. Total non-zero revenue or grand total associated with the - // transaction. This value include shipping, tax, or other adjustments to - // total revenue that you want to include as part of your revenue - // calculations. - float revenue = 2 [(google.api.field_behavior) = REQUIRED]; - - // All the taxes associated with the transaction. - float tax = 3; - - // All the costs associated with the products. These can be manufacturing - // costs, shipping expenses not borne by the end user, or any other costs, - // such that: - // - // * Profit = [revenue][google.cloud.retail.v2.PurchaseTransaction.revenue] - - // [tax][google.cloud.retail.v2.PurchaseTransaction.tax] - - // [cost][google.cloud.retail.v2.PurchaseTransaction.cost] - float cost = 4; - - // Required. Currency code. Use three-character ISO-4217 code. - string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto deleted file mode 100644 index 4446906a..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/httpbody.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/import_config.proto"; -import "google/cloud/retail/v2/purge_config.proto"; -import "google/cloud/retail/v2/user_event.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for ingesting end user actions on the customer website. -service UserEventService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Writes a single user event. - rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" - body: "user_event" - }; - } - - // Writes a single user event from the browser. This uses a GET request to - // due to browser restriction of POST-ing to a 3rd party domain. - // - // This method is used only by the Retail API JavaScript pixel and Google Tag - // Manager. Users should not call this method directly. - rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" - }; - } - - // Deletes permanently all user events specified by the filter provided. - // Depending on the number of events specified by the filter, this operation - // could take hours or days to complete. To test a filter, use the list - // command first. - rpc PurgeUserEvents(PurgeUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.PurgeUserEventsResponse" - metadata_type: "google.cloud.retail.v2.PurgeMetadata" - }; - } - - // Bulk import of User events. Request processing might be - // synchronous. Events that already exist are skipped. - // Use this method for backfilling historical user events. - // - // Operation.response is of type ImportResponse. Note that it is - // possible for a subset of the items to be successfully inserted. - // Operation.metadata is of type ImportMetadata. - rpc ImportUserEvents(ImportUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.ImportUserEventsResponse" - metadata_type: "google.cloud.retail.v2.ImportMetadata" - }; - } - - // Starts a user event rejoin operation with latest product catalog. Events - // will not be annotated with detailed product information if product is - // missing from the catalog at the time the user event is ingested, and these - // events are stored as unjoined events with a limited usage on training and - // serving. This method can be used to start a join operation on specified - // events with latest version of product catalog. It can also be used to - // correct events joined with the wrong product catalog. A rejoin operation - // can take hours or days to complete. - rpc RejoinUserEvents(RejoinUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "RejoinUserEventsResponse" - metadata_type: "RejoinUserEventsMetadata" - }; - } -} - -// Request message for WriteUserEvent method. -message WriteUserEventRequest { - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User event to write. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // Required. The parent catalog name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. URL encoded UserEvent proto with a length limit of 2,000,000 - // characters. - string user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // The URL including cgi-parameters but excluding the hash fragment with a - // length limit of 5,000 characters. This is often more useful than the - // referer URL, because many browsers only send the domain for 3rd party - // requests. - string uri = 3; - - // The event timestamp in milliseconds. This prevents browser caching of - // otherwise identical get requests. The name is abbreviated to reduce the - // payload bytes. - int64 ets = 4; -} - -// Request message for RejoinUserEvents method. -message RejoinUserEventsRequest { - // The scope of user events to be rejoined with the latest product catalog. - // If the rejoining aims at reducing number of unjoined events, set - // UserEventRejoinScope to UNJOINED_EVENTS. - // If the rejoining aims at correcting product catalog information in joined - // events, set UserEventRejoinScope to JOINED_EVENTS. - // If all events needs to be rejoined, set UserEventRejoinScope to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. - enum UserEventRejoinScope { - // Rejoin all events with the latest product catalog, including both joined - // events and unjoined events. - USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; - - // Only rejoin joined events with the latest product catalog. - JOINED_EVENTS = 1; - - // Only rejoin unjoined events with the latest product catalog. - UNJOINED_EVENTS = 2; - } - - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The type of the user event rejoin to define the scope and range of the user - // events to be rejoined with the latest product catalog. Defaults to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - // invalid integer value. - UserEventRejoinScope user_event_rejoin_scope = 2; -} - -// Response message for RejoinUserEvents method. -message RejoinUserEventsResponse { - // Number of user events that were joined with latest product catalog. - int64 rejoined_user_events_count = 1; -} - -// Metadata for RejoinUserEvents method. -message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js deleted file mode 100644 index fa840318..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2_generated_CatalogService_GetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.getDefaultBranch(request); - console.log(response); - } - - callGetDefaultBranch(); - // [END retail_v2_generated_CatalogService_GetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js deleted file mode 100644 index b5c79c51..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2_generated_CatalogService_ListCatalogs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The account resource name with an associated location. - * If the caller does not have permission to list - * Catalog google.cloud.retail.v2.Catalog s under this location, regardless - * of whether or not this location exists, a PERMISSION_DENIED error is - * returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Catalog google.cloud.retail.v2.Catalog s to return. If - * unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListCatalogsResponse.next_page_token google.cloud.retail.v2.ListCatalogsResponse.next_page_token, - * received from a previous - * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callListCatalogs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listCatalogsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCatalogs(); - // [END retail_v2_generated_CatalogService_ListCatalogs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js deleted file mode 100644 index f03f4c36..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2_generated_CatalogService_SetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * The final component of the resource name of a branch. - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * If there are no sufficient active products in the targeted branch and - * force google.cloud.retail.v2.SetDefaultBranchRequest.force is not set, a - * FAILED_PRECONDITION error is returned. - */ - // const branchId = 'abc123' - /** - * Some note on this request, this can be retrieved by - * CatalogService.GetDefaultBranch google.cloud.retail.v2.CatalogService.GetDefaultBranch - * before next valid default branch set occurs. - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const note = 'abc123' - /** - * If set to true, it permits switching to a branch with - * branch_id google.cloud.retail.v2.SetDefaultBranchRequest.branch_id even - * if it has no sufficient active products. - */ - // const force = true - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callSetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.setDefaultBranch(request); - console.log(response); - } - - callSetDefaultBranch(); - // [END retail_v2_generated_CatalogService_SetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js deleted file mode 100644 index 33d552b5..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.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(catalog) { - // [START retail_v2_generated_CatalogService_UpdateCatalog_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Catalog google.cloud.retail.v2.Catalog to update. - * If the caller does not have permission to update the - * Catalog google.cloud.retail.v2.Catalog, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * If the Catalog google.cloud.retail.v2.Catalog to update does not exist, - * a NOT_FOUND error is returned. - */ - // const catalog = {} - /** - * Indicates which fields in the provided - * Catalog google.cloud.retail.v2.Catalog to update. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCatalog() { - // Construct request - const request = { - catalog, - }; - - // Run request - const response = await retailClient.updateCatalog(request); - console.log(response); - } - - callUpdateCatalog(); - // [END retail_v2_generated_CatalogService_UpdateCatalog_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js b/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js deleted file mode 100644 index 738d1b40..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(catalog, query) { - // [START retail_v2_generated_CompletionService_CompleteQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Catalog for which the completion is performed. - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * Required. The query used to generate suggestions. - * The maximum number of allowed characters is 255. - */ - // const query = 'abc123' - /** - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see Tags for - * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - */ - // const languageCodes = 'abc123' - /** - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * Supported formats: - * * `UNKNOWN_DEVICE_TYPE` - * * `DESKTOP` - * * `MOBILE` - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - */ - // const deviceType = 'abc123' - /** - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * CompletionService.ImportCompletionData google.cloud.retail.v2.CompletionService.ImportCompletionData. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * Current supported values: - * * user-data - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - */ - // const dataset = 'abc123' - /** - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value CompletionConfig.max_suggestions . - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - */ - // const maxSuggestions = 1234 - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callCompleteQuery() { - // Construct request - const request = { - catalog, - query, - }; - - // Run request - const response = await retailClient.completeQuery(request); - console.log(response); - } - - callCompleteQuery(); - // [END retail_v2_generated_CompletionService_CompleteQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js b/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js deleted file mode 100644 index 4ccdcfe6..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.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, inputConfig) { - // [START retail_v2_generated_CompletionService_ImportCompletionData_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog which the suggestions dataset belongs to. - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callImportCompletionData() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importCompletionData(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportCompletionData(); - // [END retail_v2_generated_CompletionService_ImportCompletionData_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js b/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js deleted file mode 100644 index af3de619..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, userEvent) { - // [START retail_v2_generated_PredictionService_Predict_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see Managing - * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - */ - // const placement = 'abc123' - /** - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - */ - // const userEvent = {} - /** - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - */ - // const pageSize = 1234 - /** - * The previous PredictResponse.next_page_token. - */ - // const pageToken = 'abc123' - /** - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * Examples: - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - */ - // const filter = 'abc123' - /** - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - */ - // const validateOnly = true - /** - * Additional domain specific parameters for the predictions. - * Allowed values: - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - */ - // const params = 1234 - /** - * The labels applied to a resource must meet the following requirements: - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * See Google Cloud - * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - */ - // const labels = 1234 - - // Imports the Retail library - const {PredictionServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new PredictionServiceClient(); - - async function callPredict() { - // Construct request - const request = { - placement, - userEvent, - }; - - // Run request - const response = await retailClient.predict(request); - console.log(response); - } - - callPredict(); - // [END retail_v2_generated_PredictionService_Predict_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js b/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js deleted file mode 100644 index 79ea0522..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2_generated_ProductService_AddFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type, such as - * the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type. Duplicate - * IDs will be automatically ignored. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * If the total number of place IDs exceeds 2000 for this - * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type after - * adding, then the update will be rejected. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, the fulfillment information will still be processed and retained for - * at most 1 day and processed once the - * Product google.cloud.retail.v2.Product is created. If set to false, a - * NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddFulfillmentPlaces(); - // [END retail_v2_generated_ProductService_AddFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js b/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js deleted file mode 100644 index f0598e36..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, localInventories) { - // [START retail_v2_generated_ProductService_AddLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - */ - // const localInventories = 1234 - /** - * Indicates which inventory fields in the provided list of - * LocalInventory google.cloud.retail.v2.LocalInventory to update. The - * field is updated to the provided value. - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const addMask = {} - /** - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, the local inventory will still be processed and retained for at most - * 1 day and processed once the Product google.cloud.retail.v2.Product is - * created. If set to false, a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddLocalInventories() { - // Construct request - const request = { - product, - localInventories, - }; - - // Run request - const [operation] = await retailClient.addLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddLocalInventories(); - // [END retail_v2_generated_ProductService_AddLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js deleted file mode 100644 index e64ffbdf..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, product, productId) { - // [START retail_v2_generated_ProductService_CreateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - */ - // const parent = 'abc123' - /** - * Required. The Product google.cloud.retail.v2.Product to create. - */ - // const product = {} - /** - * Required. The ID to use for the Product google.cloud.retail.v2.Product, - * which will become the final component of the - * Product.name google.cloud.retail.v2.Product.name. - * If the caller does not have permission to create the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * This field must be unique among all - * Product google.cloud.retail.v2.Product s with the same - * parent google.cloud.retail.v2.CreateProductRequest.parent. Otherwise, an - * ALREADY_EXISTS error is returned. - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const productId = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - productId, - }; - - // Run request - const response = await retailClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END retail_v2_generated_ProductService_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js deleted file mode 100644 index 7838dfa1..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.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(name) { - // [START retail_v2_generated_ProductService_DeleteProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to delete the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2.Product to delete does not exist, - * a NOT_FOUND error is returned. - * The Product google.cloud.retail.v2.Product to delete can neither be a - * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION - * Product google.cloud.retail.v2.Product member nor a - * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY - * Product google.cloud.retail.v2.Product with more than one - * variants google.cloud.retail.v2.Product.Type.VARIANT. Otherwise, an - * INVALID_ARGUMENT error is returned. - * All inventory information for the named - * Product google.cloud.retail.v2.Product will be deleted. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END retail_v2_generated_ProductService_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js deleted file mode 100644 index 007c35ea..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2_generated_ProductService_GetProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * If the requested Product google.cloud.retail.v2.Product does not exist, - * a NOT_FOUND error is returned. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END retail_v2_generated_ProductService_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js b/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js deleted file mode 100644 index 39cc5522..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2_generated_ProductService_ImportProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. - */ - // const errorsConfig = {} - /** - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - */ - // const updateMask = {} - /** - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * ReconciliationMode.INCREMENTAL google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL. - */ - // const reconciliationMode = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * Only supported when - * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode - * is set to `FULL`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callImportProducts() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProducts(); - // [END retail_v2_generated_ProductService_ImportProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js b/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js deleted file mode 100644 index 00b71a9a..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2_generated_ProductService_ListProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * If the caller does not have permission to list - * Product google.cloud.retail.v2.Product s under this branch, regardless of - * whether or not this branch exists, a PERMISSION_DENIED error is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Product google.cloud.retail.v2.Product s to return. If - * unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT error is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListProductsResponse.next_page_token google.cloud.retail.v2.ListProductsResponse.next_page_token, - * received from a previous - * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2.ListProductsRequest.filter is unset. - * * List Product.Type.VARIANT google.cloud.retail.v2.Product.Type.VARIANT - * Product google.cloud.retail.v2.Product s sharing the same - * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY - * Product google.cloud.retail.v2.Product. For example: - * `primary_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2.Product s bundled in a - * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION - * Product google.cloud.retail.v2.Product. - * For example: - * `collection_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2.Product s with a partibular type. - * For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * If the specified - * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY - * Product google.cloud.retail.v2.Product or - * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION - * Product google.cloud.retail.v2.Product does not exist, a NOT_FOUND error - * is returned. - */ - // const filter = 'abc123' - /** - * The fields of Product google.cloud.retail.v2.Product to return in the - * responses. If not set or empty, the following fields are returned: - * * Product.name google.cloud.retail.v2.Product.name - * * Product.id google.cloud.retail.v2.Product.id - * * Product.title google.cloud.retail.v2.Product.title - * * Product.uri google.cloud.retail.v2.Product.uri - * * Product.images google.cloud.retail.v2.Product.images - * * Product.price_info google.cloud.retail.v2.Product.price_info - * * Product.brands google.cloud.retail.v2.Product.brands - * If "*" is provided, all fields are returned. - * Product.name google.cloud.retail.v2.Product.name is always returned no - * matter what mask is set. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const readMask = {} - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END retail_v2_generated_ProductService_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js deleted file mode 100644 index 3be188b8..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type, such as - * the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, the fulfillment information will still be processed and retained for - * at most 1 day and processed once the - * Product google.cloud.retail.v2.Product is created. If set to false, a - * NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveFulfillmentPlaces(); - // [END retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js deleted file mode 100644 index 6332ed05..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, placeIds) { - // [START retail_v2_generated_ProductService_RemoveLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - */ - // const placeIds = 'abc123' - /** - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * Product google.cloud.retail.v2.Product is created. If set to false, a - * NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveLocalInventories() { - // Construct request - const request = { - product, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveLocalInventories(); - // [END retail_v2_generated_ProductService_RemoveLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js b/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js deleted file mode 100644 index 4f35c54e..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js +++ /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 -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(inventory) { - // [START retail_v2_generated_ProductService_SetInventory_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The inventory information to update. The allowable fields to - * update are: - * * Product.price_info google.cloud.retail.v2.Product.price_info - * * Product.availability google.cloud.retail.v2.Product.availability - * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info - * The updated inventory fields must be specified in - * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask. - * If SetInventoryRequest.inventory.name is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2.Product named in - * Product.name google.cloud.retail.v2.Product.name, regardless of whether - * or not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2.Product to update does not have - * existing inventory information, the provided inventory information will be - * inserted. - * If the Product google.cloud.retail.v2.Product to update has existing - * inventory information, the provided inventory information will be merged - * while respecting the last update time for each inventory field, using the - * provided or default value for - * SetInventoryRequest.set_time google.cloud.retail.v2.SetInventoryRequest.set_time. - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in SetInventoryRequest.inventory.fulfillment_info - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types to clear in - * SetInventoryRequest.inventory.fulfillment_info - * * Checks that only the desired fulfillment info types have empty - * SetInventoryRequest.inventory.fulfillment_info.place_ids - * The last update time is recorded for the following inventory fields: - * * Product.price_info google.cloud.retail.v2.Product.price_info - * * Product.availability google.cloud.retail.v2.Product.availability - * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info - * If a full overwrite of inventory information while ignoring timestamps is - * needed, UpdateProduct should be invoked instead. - */ - // const inventory = {} - /** - * Indicates which inventory fields in the provided - * Product google.cloud.retail.v2.Product to update. - * At least one field must be provided. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const setMask = {} - /** - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - */ - // const setTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product with name - * Product.name google.cloud.retail.v2.Product.name is not found, the - * inventory update will still be processed and retained for at most 1 day - * until the Product google.cloud.retail.v2.Product is created. If set to - * false, a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callSetInventory() { - // Construct request - const request = { - inventory, - }; - - // Run request - const [operation] = await retailClient.setInventory(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInventory(); - // [END retail_v2_generated_ProductService_SetInventory_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js deleted file mode 100644 index 359a30ef..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START retail_v2_generated_ProductService_UpdateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The product to update/create. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2.Product to update does not exist - * and - * allow_missing google.cloud.retail.v2.UpdateProductRequest.allow_missing - * is not set, a NOT_FOUND error is returned. - */ - // const product = {} - /** - * Indicates which fields in the provided - * Product google.cloud.retail.v2.Product to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, a new Product google.cloud.retail.v2.Product will be created. In - * this situation, `update_mask` is ignored. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await retailClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END retail_v2_generated_ProductService_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/search_service.search.js b/owl-bot-staging/v2/samples/generated/v2/search_service.search.js deleted file mode 100644 index 2083811f..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/search_service.search.js +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, visitorId) { - // [START retail_v2_generated_SearchService_Search_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - */ - // const placement = 'abc123' - /** - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - */ - // const branch = 'abc123' - /** - * Raw search query. - */ - // const query = 'abc123' - /** - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * This should be the same identifier as - * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * User information. - */ - // const userInfo = {} - /** - * Maximum number of Product google.cloud.retail.v2.Product s to return. If - * unspecified, defaults to a reasonable value. The maximum allowed value is - * 120. Values above 120 will be coerced to 120. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * SearchResponse.next_page_token google.cloud.retail.v2.SearchResponse.next_page_token, - * received from a previous - * SearchService.Search google.cloud.retail.v2.SearchService.Search call. - * Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SearchService.Search google.cloud.retail.v2.SearchService.Search must - * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - * error is returned. - */ - // const pageToken = 'abc123' - /** - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the Product google.cloud.retail.v2.Product s - * deemed by the API as relevant) in search results. This field is only - * considered if page_token google.cloud.retail.v2.SearchRequest.page_token - * is unset. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const offset = 1234 - /** - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const filter = 'abc123' - /** - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * SearchRequest.canonical_filter google.cloud.retail.v2.SearchRequest.canonical_filter - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * See SearchRequest.filter google.cloud.retail.v2.SearchRequest.filter for - * more details about filter syntax. - */ - // const canonicalFilter = 'abc123' - /** - * The order in which products are returned. Products can be ordered by - * a field in an Product google.cloud.retail.v2.Product object. Leave it - * unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#order). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const orderBy = 'abc123' - /** - * Facet specifications for faceted search. If empty, no facets are returned. - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - */ - // const facetSpecs = 1234 - /** - * Boost specification to boost certain products. See more details at this - * user guide (https://cloud.google.com/retail/docs/boosting). - * Notice that if both ServingConfig.boost_control_ids and - * SearchRequest.boost_spec are set, the boost conditions from both places - * are evaluated. If a search request matches multiple boost conditions, - * the final boost score is equal to the sum of the boost scores from all - * matched boost conditions. - */ - // const boostSpec = {} - /** - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this user - * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). - */ - // const queryExpansionSpec = {} - /** - * The keys to fetch and rollup the matching - * variant google.cloud.retail.v2.Product.Type.VARIANT - * Product google.cloud.retail.v2.Product s attributes, - * FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo or - * LocalInventory google.cloud.retail.v2.LocalInventory s attributes. The - * attributes from all the matching - * variant google.cloud.retail.v2.Product.Type.VARIANT - * Product google.cloud.retail.v2.Product s or - * LocalInventory google.cloud.retail.v2.LocalInventory s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * For FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * Supported keys are: - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * Product.inventories.attributes map. - * * attributes.key, where key is any key in the - * Product.attributes google.cloud.retail.v2.Product.attributes map. - * * pickupInStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "pickup-in-store". - * * shipToStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-1". - * * customFulfillment2.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-2". - * * customFulfillment3.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-3". - * * customFulfillment4.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-4". - * * customFulfillment5.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-5". - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - */ - // const variantRollupKeys = 'abc123' - /** - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * UserEvent.page_categories google.cloud.retail.v2.UserEvent.page_categories; - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : "Sales > 2017 Black Friday Deals". - */ - // const pageCategories = 'abc123' - /** - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - */ - // const searchMode = {} - /** - * The specification for personalization. - */ - // const personalizationSpec = {} - - // Imports the Retail library - const {SearchServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new SearchServiceClient(); - - async function callSearch() { - // Construct request - const request = { - placement, - visitorId, - }; - - // Run request - const iterable = await retailClient.searchAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearch(); - // [END retail_v2_generated_SearchService_Search_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json deleted file mode 100644 index 6dbcb263..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json +++ /dev/null @@ -1,1295 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-retail", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.retail.v2", - "version": "v2" - } - ] - }, - "snippets": [ - { - "regionTag": "retail_v2_generated_CatalogService_ListCatalogs_async", - "title": "CatalogService listCatalogs Sample", - "origin": "API_DEFINITION", - "description": " Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with the project.", - "canonical": true, - "file": "catalog_service.list_catalogs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.ListCatalogsResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_UpdateCatalog_async", - "title": "CatalogService updateCatalog Sample", - "origin": "API_DEFINITION", - "description": " Updates the [Catalog][google.cloud.retail.v2.Catalog]s.", - "canonical": true, - "file": "catalog_service.update_catalog.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": ".google.cloud.retail.v2.Catalog" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.Catalog", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_SetDefaultBranch_async", - "title": "CatalogService setDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", - "canonical": true, - "file": "catalog_service.set_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "branch_id", - "type": "TYPE_STRING" - }, - { - "name": "note", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_GetDefaultBranch_async", - "title": "CatalogService getDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] method under a specified parent catalog.", - "canonical": true, - "file": "catalog_service.get_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.GetDefaultBranchResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CompletionService_CompleteQuery_async", - "title": "CatalogService completeQuery Sample", - "origin": "API_DEFINITION", - "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 108, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "language_codes", - "type": "TYPE_STRING[]" - }, - { - "name": "device_type", - "type": "TYPE_STRING" - }, - { - "name": "dataset", - "type": "TYPE_STRING" - }, - { - "name": "max_suggestions", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.retail.v2.CompleteQueryResponse", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2.CompletionServiceClient" - }, - "method": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CompletionService_ImportCompletionData_async", - "title": "CatalogService importCompletionData Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.import_completion_data.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2.CompletionDataInputConfig" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2.CompletionServiceClient" - }, - "method": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_PredictionService_Predict_async", - "title": "CatalogService predict Sample", - "origin": "API_DEFINITION", - "description": " Makes a recommendation prediction.", - "canonical": true, - "file": "prediction_service.predict.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 153, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2.PredictionService.Predict", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2.UserEvent" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "params", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.retail.v2.PredictResponse", - "client": { - "shortName": "PredictionServiceClient", - "fullName": "google.cloud.retail.v2.PredictionServiceClient" - }, - "method": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2.PredictionService.Predict", - "service": { - "shortName": "PredictionService", - "fullName": "google.cloud.retail.v2.PredictionService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_CreateProduct_async", - "title": "CatalogService createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Product][google.cloud.retail.v2.Product].", - "canonical": true, - "file": "product_service.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.retail.v2.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_GetProduct_async", - "title": "CatalogService getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Product][google.cloud.retail.v2.Product].", - "canonical": true, - "file": "product_service.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2.ProductService.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2.ProductService.GetProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_ListProducts_async", - "title": "CatalogService listProducts Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Product][google.cloud.retail.v2.Product]s.", - "canonical": true, - "file": "product_service.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 122, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2.ProductService.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "read_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.ListProductsResponse", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2.ProductService.ListProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_UpdateProduct_async", - "title": "CatalogService updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Product][google.cloud.retail.v2.Product].", - "canonical": true, - "file": "product_service.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.retail.v2.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.retail.v2.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_DeleteProduct_async", - "title": "CatalogService deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Product][google.cloud.retail.v2.Product].", - "canonical": true, - "file": "product_service.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_ImportProducts_async", - "title": "CatalogService importProducts Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2.Product]s to be successfully updated.", - "canonical": true, - "file": "product_service.import_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 85, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2.ProductInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2.ImportErrorsConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "reconciliation_mode", - "type": ".google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_SetInventory_async", - "title": "CatalogService setInventory Sample", - "origin": "API_DEFINITION", - "description": " Updates inventory information for a [Product][google.cloud.retail.v2.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.set_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 116, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2.ProductService.SetInventory", - "async": true, - "parameters": [ - { - "name": "inventory", - "type": ".google.cloud.retail.v2.Product" - }, - { - "name": "set_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "set_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2.ProductService.SetInventory", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_AddFulfillmentPlaces_async", - "title": "CatalogService addFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 107, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async", - "title": "CatalogService removeFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 103, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_AddLocalInventories_async", - "title": "CatalogService addLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Updates local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 91, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "local_inventories", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "add_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_RemoveLocalInventories_async", - "title": "CatalogService removeLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Remove local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_SearchService_Search_async", - "title": "CatalogService search Sample", - "origin": "API_DEFINITION", - "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 252, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2.SearchService.Search", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "branch", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "user_info", - "type": ".google.cloud.retail.v2.UserInfo" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "offset", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "canonical_filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "facet_specs", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "dynamic_facet_spec", - "type": ".google.cloud.retail.v2.SearchRequest.DynamicFacetSpec" - }, - { - "name": "boost_spec", - "type": ".google.cloud.retail.v2.SearchRequest.BoostSpec" - }, - { - "name": "query_expansion_spec", - "type": ".google.cloud.retail.v2.SearchRequest.QueryExpansionSpec" - }, - { - "name": "variant_rollup_keys", - "type": "TYPE_STRING[]" - }, - { - "name": "page_categories", - "type": "TYPE_STRING[]" - }, - { - "name": "search_mode", - "type": ".google.cloud.retail.v2.SearchRequest.SearchMode" - }, - { - "name": "personalization_spec", - "type": ".google.cloud.retail.v2.SearchRequest.PersonalizationSpec" - } - ], - "resultType": ".google.cloud.retail.v2.SearchResponse", - "client": { - "shortName": "SearchServiceClient", - "fullName": "google.cloud.retail.v2.SearchServiceClient" - }, - "method": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2.SearchService.Search", - "service": { - "shortName": "SearchService", - "fullName": "google.cloud.retail.v2.SearchService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_WriteUserEvent_async", - "title": "CatalogService writeUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event.", - "canonical": true, - "file": "user_event_service.write_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2.UserEvent" - } - ], - "resultType": ".google.cloud.retail.v2.UserEvent", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_CollectUserEvent_async", - "title": "CatalogService collectUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", - "canonical": true, - "file": "user_event_service.collect_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.api.HttpBody", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_PurgeUserEvents_async", - "title": "CatalogService purgeUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", - "canonical": true, - "file": "user_event_service.purge_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 82, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_ImportUserEvents_async", - "title": "CatalogService importUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", - "canonical": true, - "file": "user_event_service.import_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2.UserEventInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2.ImportErrorsConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_RejoinUserEvents_async", - "title": "CatalogService rejoinUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", - "canonical": true, - "file": "user_event_service.rejoin_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event_rejoin_scope", - "type": ".google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js deleted file mode 100644 index 40992711..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2_generated_UserEventService_CollectUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - */ - // const userEvent = 'abc123' - /** - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - */ - // const uri = 'abc123' - /** - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - */ - // const ets = 1234 - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callCollectUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.collectUserEvent(request); - console.log(response); - } - - callCollectUserEvent(); - // [END retail_v2_generated_UserEventService_CollectUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js deleted file mode 100644 index fa18d38d..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2_generated_UserEventService_ImportUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. `projects/1234/locations/global/catalogs/default_catalog` - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - */ - // const errorsConfig = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callImportUserEvents() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportUserEvents(); - // [END retail_v2_generated_UserEventService_ImportUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js deleted file mode 100644 index 0a008d5d..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, filter) { - // [START retail_v2_generated_UserEventService_PurgeUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - */ - // const parent = 'abc123' - /** - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * * `eventType`: Double quoted - * UserEvent.event_type google.cloud.retail.v2.UserEvent.event_type string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * Examples: - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * The filtering fields are assumed to have an implicit AND. - */ - // const filter = 'abc123' - /** - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - */ - // const force = true - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callPurgeUserEvents() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await retailClient.purgeUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeUserEvents(); - // [END retail_v2_generated_UserEventService_PurgeUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js deleted file mode 100644 index 925f96b6..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2_generated_UserEventService_RejoinUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - */ - // const userEventRejoinScope = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callRejoinUserEvents() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await retailClient.rejoinUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRejoinUserEvents(); - // [END retail_v2_generated_UserEventService_RejoinUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js deleted file mode 100644 index 6df073a3..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2_generated_UserEventService_WriteUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callWriteUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.writeUserEvent(request); - console.log(response); - } - - callWriteUserEvent(); - // [END retail_v2_generated_UserEventService_WriteUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/src/index.ts b/owl-bot-staging/v2/src/index.ts deleted file mode 100644 index 28988c03..00000000 --- a/owl-bot-staging/v2/src/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 v2 from './v2'; -const CatalogServiceClient = v2.CatalogServiceClient; -type CatalogServiceClient = v2.CatalogServiceClient; -const CompletionServiceClient = v2.CompletionServiceClient; -type CompletionServiceClient = v2.CompletionServiceClient; -const PredictionServiceClient = v2.PredictionServiceClient; -type PredictionServiceClient = v2.PredictionServiceClient; -const ProductServiceClient = v2.ProductServiceClient; -type ProductServiceClient = v2.ProductServiceClient; -const SearchServiceClient = v2.SearchServiceClient; -type SearchServiceClient = v2.SearchServiceClient; -const UserEventServiceClient = v2.UserEventServiceClient; -type UserEventServiceClient = v2.UserEventServiceClient; -export {v2, CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient}; -export default {v2, CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_client.ts b/owl-bot-staging/v2/src/v2/catalog_service_client.ts deleted file mode 100644 index c8d68a6b..00000000 --- a/owl-bot-staging/v2/src/v2/catalog_service_client.ts +++ /dev/null @@ -1,1058 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/catalog_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './catalog_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for managing catalog configuration. - * @class - * @memberof v2 - */ -export class CatalogServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - catalogServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CatalogServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CatalogServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listCatalogs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.CatalogService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.catalogServiceStub) { - return this.catalogServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.CatalogService. - this.catalogServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.CatalogService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.CatalogService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const catalogServiceStubMethods = - ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch']; - for (const methodName of catalogServiceStubMethods) { - const callPromise = this.catalogServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.catalogServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Updates the {@link google.cloud.retail.v2.Catalog|Catalog}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2.Catalog} request.catalog - * Required. The {@link google.cloud.retail.v2.Catalog|Catalog} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2.Catalog|Catalog}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2.Catalog|Catalog} to update does not exist, - * a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2.Catalog|Catalog} to update. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2.Catalog}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/catalog_service.update_catalog.js - * region_tag:retail_v2_generated_CatalogService_UpdateCatalog_async - */ - updateCatalog( - request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|undefined, {}|undefined - ]>; - updateCatalog( - request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, - callback: Callback< - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog.name': request.catalog!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCatalog(request, options, callback); - } -/** - * Set a specified branch id as default branch. API methods such as - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search}, - * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct}, - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * will treat requests using "default_branch" to the actual branch id set as - * default. - * - * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as - * default, setting - * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent - * to setting - * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/1`. - * - * Using multiple branches can be useful when developers would like - * to have a staging branch to test and verify for future usage. When it - * becomes ready, developers switch on the staging branch using this API while - * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` - * as {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to - * route the traffic to this staging branch. - * - * CAUTION: If you have live predict/search traffic, switching the default - * branch could potentially cause outages if the ID space of the new branch is - * very different from the old one. - * - * More specifically: - * - * * PredictionService will only return product IDs from branch {newBranch}. - * * SearchService will only return product IDs from branch {newBranch} - * (if branch is not explicitly set). - * * UserEventService will only join events with products from branch - * {newBranch}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.branchId - * The final component of the resource name of a branch. - * - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * - * If there are no sufficient active products in the targeted branch and - * {@link google.cloud.retail.v2.SetDefaultBranchRequest.force|force} is not set, a - * FAILED_PRECONDITION error is returned. - * @param {string} request.note - * Some note on this request, this can be retrieved by - * {@link google.cloud.retail.v2.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} - * before next valid default branch set occurs. - * - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {boolean} request.force - * If set to true, it permits switching to a branch with - * {@link google.cloud.retail.v2.SetDefaultBranchRequest.branch_id|branch_id} even - * if it has no sufficient active products. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/catalog_service.set_default_branch.js - * region_tag:retail_v2_generated_CatalogService_SetDefaultBranch_async - */ - setDefaultBranch( - request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|undefined, {}|undefined - ]>; - setDefaultBranch( - request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.setDefaultBranch(request, options, callback); - } -/** - * Get which branch is currently default branch set by - * {@link google.cloud.retail.v2.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} - * method under a specified parent catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2.GetDefaultBranchResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/catalog_service.get_default_branch.js - * region_tag:retail_v2_generated_CatalogService_GetDefaultBranch_async - */ - getDefaultBranch( - request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|undefined, {}|undefined - ]>; - getDefaultBranch( - request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, - callback: Callback< - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.getDefaultBranch(request, options, callback); - } - - /** - * Lists all the {@link google.cloud.retail.v2.Catalog|Catalog}s associated with - * the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless - * of whether or not this location exists, a PERMISSION_DENIED error is - * returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If - * unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2.Catalog}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogs( - request?: protos.google.cloud.retail.v2.IListCatalogsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.ICatalog[], - protos.google.cloud.retail.v2.IListCatalogsRequest|null, - protos.google.cloud.retail.v2.IListCatalogsResponse - ]>; - listCatalogs( - request: protos.google.cloud.retail.v2.IListCatalogsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListCatalogsRequest, - protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2.ICatalog>): void; - listCatalogs( - request: protos.google.cloud.retail.v2.IListCatalogsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListCatalogsRequest, - protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2.ICatalog>): void; - listCatalogs( - request?: protos.google.cloud.retail.v2.IListCatalogsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2.IListCatalogsRequest, - protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2.ICatalog>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2.IListCatalogsRequest, - protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2.ICatalog>): - Promise<[ - protos.google.cloud.retail.v2.ICatalog[], - protos.google.cloud.retail.v2.IListCatalogsRequest|null, - protos.google.cloud.retail.v2.IListCatalogsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listCatalogs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless - * of whether or not this location exists, a PERMISSION_DENIED error is - * returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If - * unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2.Catalog} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogsStream( - request?: protos.google.cloud.retail.v2.IListCatalogsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.createStream( - this.innerApiCalls.listCatalogs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listCatalogs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless - * of whether or not this location exists, a PERMISSION_DENIED error is - * returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If - * unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Catalog]{@link google.cloud.retail.v2.Catalog}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/catalog_service.list_catalogs.js - * region_tag:retail_v2_generated_CatalogService_ListCatalogs_async - */ - listCatalogsAsync( - request?: protos.google.cloud.retail.v2.IListCatalogsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.asyncIterate( - this.innerApiCalls['listCatalogs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.catalogServiceStub && !this._terminated) { - return this.catalogServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_client_config.json b/owl-bot-staging/v2/src/v2/catalog_service_client_config.json deleted file mode 100644 index dd5a76fa..00000000 --- a/owl-bot-staging/v2/src/v2/catalog_service_client_config.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.CatalogService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListCatalogs": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCatalog": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "SetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json b/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/completion_service_client.ts b/owl-bot-staging/v2/src/v2/completion_service_client.ts deleted file mode 100644 index 086944c6..00000000 --- a/owl-bot-staging/v2/src/v2/completion_service_client.ts +++ /dev/null @@ -1,701 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/completion_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './completion_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Auto-completion service for retail. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2 - */ -export class CompletionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - completionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CompletionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CompletionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importCompletionDataResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportCompletionDataResponse') as gax.protobuf.Type; - const importCompletionDataMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importCompletionData: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importCompletionDataResponse.decode.bind(importCompletionDataResponse), - importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.CompletionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.completionServiceStub) { - return this.completionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.CompletionService. - this.completionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.CompletionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.CompletionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const completionServiceStubMethods = - ['completeQuery', 'importCompletionData']; - for (const methodName of completionServiceStubMethods) { - const callPromise = this.completionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.completionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Completes the specified prefix with keyword suggestions. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Required. Catalog for which the completion is performed. - * - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.query - * Required. The query used to generate suggestions. - * - * The maximum number of allowed characters is 255. - * @param {string} request.visitorId - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {string[]} request.languageCodes - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see [Tags for - * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - * @param {string} request.deviceType - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * - * Supported formats: - * - * * `UNKNOWN_DEVICE_TYPE` - * - * * `DESKTOP` - * - * * `MOBILE` - * - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - * @param {string} request.dataset - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * {@link google.cloud.retail.v2.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * - * Current supported values: - * - * * user-data - * - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - * @param {number} request.maxSuggestions - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value {@link |CompletionConfig.max_suggestions}. - * - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2.CompleteQueryResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/completion_service.complete_query.js - * region_tag:retail_v2_generated_CompletionService_CompleteQuery_async - */ - completeQuery( - request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|undefined, {}|undefined - ]>; - completeQuery( - request: protos.google.cloud.retail.v2.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request: protos.google.cloud.retail.v2.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.completeQuery(request, options, callback); - } - -/** - * Bulk import of processed completion dataset. - * - * Request processing is asynchronous. Partial updating is not supported. - * - * The operation is successfully finished only after the imported suggestions - * are indexed successfully and ready for serving. The process takes hours. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog which the suggestions dataset belongs to. - * - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2.CompletionDataInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/completion_service.import_completion_data.js - * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async - */ - importCompletionData( - request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importCompletionData( - request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importCompletionData(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importCompletionData()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/completion_service.import_completion_data.js - * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async - */ - async checkImportCompletionDataProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.completionServiceStub && !this._terminated) { - return this.completionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/completion_service_client_config.json b/owl-bot-staging/v2/src/v2/completion_service_client_config.json deleted file mode 100644 index a6bffad0..00000000 --- a/owl-bot-staging/v2/src/v2/completion_service_client_config.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.CompletionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CompleteQuery": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ImportCompletionData": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/completion_service_proto_list.json b/owl-bot-staging/v2/src/v2/completion_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/completion_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/gapic_metadata.json b/owl-bot-staging/v2/src/v2/gapic_metadata.json deleted file mode 100644 index e2fe1b36..00000000 --- a/owl-bot-staging/v2/src/v2/gapic_metadata.json +++ /dev/null @@ -1,345 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.retail.v2", - "libraryPackage": "@google-cloud/retail", - "services": { - "CatalogService": { - "clients": { - "grpc": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - } - } - }, - "CompletionService": { - "clients": { - "grpc": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - } - } - }, - "PredictionService": { - "clients": { - "grpc": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - } - } - }, - "ProductService": { - "clients": { - "grpc": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - } - } - }, - "SearchService": { - "clients": { - "grpc": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - } - } - }, - "UserEventService": { - "clients": { - "grpc": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/index.ts b/owl-bot-staging/v2/src/v2/index.ts deleted file mode 100644 index 79cde8aa..00000000 --- a/owl-bot-staging/v2/src/v2/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {CatalogServiceClient} from './catalog_service_client'; -export {CompletionServiceClient} from './completion_service_client'; -export {PredictionServiceClient} from './prediction_service_client'; -export {ProductServiceClient} from './product_service_client'; -export {SearchServiceClient} from './search_service_client'; -export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2/src/v2/prediction_service_client.ts b/owl-bot-staging/v2/src/v2/prediction_service_client.ts deleted file mode 100644 index a38a7013..00000000 --- a/owl-bot-staging/v2/src/v2/prediction_service_client.ts +++ /dev/null @@ -1,603 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/prediction_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './prediction_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for making recommendation prediction. - * @class - * @memberof v2 - */ -export class PredictionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - predictionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PredictionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PredictionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.PredictionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.predictionServiceStub) { - return this.predictionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.PredictionService. - this.predictionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.PredictionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.PredictionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const predictionServiceStubMethods = - ['predict']; - for (const methodName of predictionServiceStubMethods) { - const callPromise = this.predictionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.predictionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Makes a recommendation prediction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see [Managing - * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - * @param {google.cloud.retail.v2.UserEvent} request.userEvent - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - * @param {number} request.pageSize - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - * @param {string} request.pageToken - * The previous PredictResponse.next_page_token. - * @param {string} request.filter - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * - * Examples: - * - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - * @param {boolean} request.validateOnly - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - * @param {number[]} request.params - * Additional domain specific parameters for the predictions. - * - * Allowed values: - * - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - * @param {number[]} request.labels - * The labels applied to a resource must meet the following requirements: - * - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * - * See [Google Cloud - * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2.PredictResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/prediction_service.predict.js - * region_tag:retail_v2_generated_PredictionService_Predict_async - */ - predict( - request?: protos.google.cloud.retail.v2.IPredictRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|undefined, {}|undefined - ]>; - predict( - request: protos.google.cloud.retail.v2.IPredictRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request: protos.google.cloud.retail.v2.IPredictRequest, - callback: Callback< - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request?: protos.google.cloud.retail.v2.IPredictRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.predict(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.predictionServiceStub && !this._terminated) { - return this.predictionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/prediction_service_client_config.json b/owl-bot-staging/v2/src/v2/prediction_service_client_config.json deleted file mode 100644 index 9ab95d31..00000000 --- a/owl-bot-staging/v2/src/v2/prediction_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.PredictionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Predict": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json b/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/product_service_client.ts b/owl-bot-staging/v2/src/v2/product_service_client.ts deleted file mode 100644 index e61bc990..00000000 --- a/owl-bot-staging/v2/src/v2/product_service_client.ts +++ /dev/null @@ -1,2210 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/product_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting {@link google.cloud.retail.v2.Product|Product} information - * of the customer's website. - * @class - * @memberof v2 - */ -export class ProductServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ProductServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importProductsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportProductsResponse') as gax.protobuf.Type; - const importProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; - const setInventoryResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.SetInventoryResponse') as gax.protobuf.Type; - const setInventoryMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.SetInventoryMetadata') as gax.protobuf.Type; - const addFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.AddFulfillmentPlacesResponse') as gax.protobuf.Type; - const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; - const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; - const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; - const addLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.AddLocalInventoriesResponse') as gax.protobuf.Type; - const addLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.AddLocalInventoriesMetadata') as gax.protobuf.Type; - const removeLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RemoveLocalInventoriesResponse') as gax.protobuf.Type; - const removeLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductsResponse.decode.bind(importProductsResponse), - importProductsMetadata.decode.bind(importProductsMetadata)), - setInventory: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInventoryResponse.decode.bind(setInventoryResponse), - setInventoryMetadata.decode.bind(setInventoryMetadata)), - addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), - addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), - removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), - removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), - addLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), - addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), - removeLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), - removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.ProductService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.productServiceStub) { - return this.productServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.ProductService. - this.productServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ProductService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.ProductService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const productServiceStubMethods = - ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; - for (const methodName of productServiceStubMethods) { - const callPromise = this.productServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.productServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a {@link google.cloud.retail.v2.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - * @param {google.cloud.retail.v2.Product} request.product - * Required. The {@link google.cloud.retail.v2.Product|Product} to create. - * @param {string} request.productId - * Required. The ID to use for the {@link google.cloud.retail.v2.Product|Product}, - * which will become the final component of the - * {@link google.cloud.retail.v2.Product.name|Product.name}. - * - * If the caller does not have permission to create the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * This field must be unique among all - * {@link google.cloud.retail.v2.Product|Product}s with the same - * {@link google.cloud.retail.v2.CreateProductRequest.parent|parent}. Otherwise, an - * ALREADY_EXISTS error is returned. - * - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/product_service.create_product.js - * region_tag:retail_v2_generated_ProductService_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.retail.v2.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.retail.v2.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.retail.v2.ICreateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.retail.v2.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the requested {@link google.cloud.retail.v2.Product|Product} does not exist, - * a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/product_service.get_product.js - * region_tag:retail_v2_generated_ProductService_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.retail.v2.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.retail.v2.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.retail.v2.IGetProductRequest, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.retail.v2.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Updates a {@link google.cloud.retail.v2.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2.Product} request.product - * Required. The product to update/create. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2.Product|Product} to update does not exist - * and - * {@link google.cloud.retail.v2.UpdateProductRequest.allow_missing|allow_missing} - * is not set, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2.Product|Product} to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, a new {@link google.cloud.retail.v2.Product|Product} will be created. In - * this situation, `update_mask` is ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/product_service.update_product.js - * region_tag:retail_v2_generated_ProductService_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.retail.v2.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.retail.v2.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.retail.v2.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.retail.v2.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Deletes a {@link google.cloud.retail.v2.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to delete the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2.Product|Product} to delete does not exist, - * a NOT_FOUND error is returned. - * - * The {@link google.cloud.retail.v2.Product|Product} to delete can neither be a - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product} member nor a - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product} with more than one - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variants}. Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * All inventory information for the named - * {@link google.cloud.retail.v2.Product|Product} will be deleted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/product_service.delete_product.js - * region_tag:retail_v2_generated_ProductService_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.retail.v2.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.retail.v2.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.retail.v2.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.retail.v2.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } - -/** - * Bulk import of multiple {@link google.cloud.retail.v2.Product|Product}s. - * - * Request processing may be synchronous. No partial updating is supported. - * Non-existing items are created. - * - * Note that it is possible for a subset of the - * {@link google.cloud.retail.v2.Product|Product}s to be successfully updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - * @param {string} request.requestId - * Deprecated. This field has no effect. - * @param {google.cloud.retail.v2.ProductInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - * @param {google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode} request.reconciliationMode - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * {@link google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * - * Only supported when - * {@link google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} - * is set to `FULL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.import_products.js - * region_tag:retail_v2_generated_ProductService_ImportProducts_async - */ - importProducts( - request?: protos.google.cloud.retail.v2.IImportProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProducts( - request: protos.google.cloud.retail.v2.IImportProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request: protos.google.cloud.retail.v2.IImportProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request?: protos.google.cloud.retail.v2.IImportProductsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.import_products.js - * region_tag:retail_v2_generated_ProductService_ImportProducts_async - */ - async checkImportProductsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates inventory information for a - * {@link google.cloud.retail.v2.Product|Product} while respecting the last update - * timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, updates are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * When inventory is updated with - * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct}, the - * specified inventory field value(s) will overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update time for the specified inventory fields will be overwritten to the - * time of the - * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} or - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} - * request. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2.CreateProductRequest.product|CreateProductRequest.product}, - * then any pre-existing inventory information for this product will be used. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, - * then any existing inventory information will be preserved. - * - * Pre-existing inventory information can only be updated with - * {@link google.cloud.retail.v2.ProductService.SetInventory|SetInventory}, - * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, - * and - * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2.Product} request.inventory - * Required. The inventory information to update. The allowable fields to - * update are: - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} - * The updated inventory fields must be specified in - * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. - * - * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2.Product|Product} named in - * {@link google.cloud.retail.v2.Product.name|Product.name}, regardless of whether - * or not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2.Product|Product} to update does not have - * existing inventory information, the provided inventory information will be - * inserted. - * - * If the {@link google.cloud.retail.v2.Product|Product} to update has existing - * inventory information, the provided inventory information will be merged - * while respecting the last update time for each inventory field, using the - * provided or default value for - * {@link google.cloud.retail.v2.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. - * - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} - * - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types to clear in - * {@link |SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} - * - * The last update time is recorded for the following inventory fields: - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} - * - * If a full overwrite of inventory information while ignoring timestamps is - * needed, {@link |UpdateProduct} should be invoked instead. - * @param {google.protobuf.FieldMask} request.setMask - * Indicates which inventory fields in the provided - * {@link google.cloud.retail.v2.Product|Product} to update. - * - * At least one field must be provided. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.setTime - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} with name - * {@link google.cloud.retail.v2.Product.name|Product.name} is not found, the - * inventory update will still be processed and retained for at most 1 day - * until the {@link google.cloud.retail.v2.Product|Product} is created. If set to - * false, a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.set_inventory.js - * region_tag:retail_v2_generated_ProductService_SetInventory_async - */ - setInventory( - request?: protos.google.cloud.retail.v2.ISetInventoryRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInventory( - request: protos.google.cloud.retail.v2.ISetInventoryRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request: protos.google.cloud.retail.v2.ISetInventoryRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request?: protos.google.cloud.retail.v2.ISetInventoryRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'inventory.name': request.inventory!.name || '', - }); - this.initialize(); - return this.innerApiCalls.setInventory(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInventory()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.set_inventory.js - * region_tag:retail_v2_generated_ProductService_SetInventory_async - */ - async checkSetInventoryProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally adds place IDs to - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the added place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}, such as - * the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}. Duplicate - * IDs will be automatically ignored. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * If the total number of place IDs exceeds 2000 for this - * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type} after - * adding, then the update will be rejected. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, the fulfillment information will still be processed and retained for - * at most 1 day and processed once the - * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a - * NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.add_fulfillment_places.js - * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async - */ - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.add_fulfillment_places.js - * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async - */ - async checkAddFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally removes place IDs from a - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the removed place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}, such as - * the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, the fulfillment information will still be processed and retained for - * at most 1 day and processed once the - * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a - * NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js - * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async - */ - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js - * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async - */ - async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates local inventory information for a - * {@link google.cloud.retail.v2.Product|Product} at a list of places, while - * respecting the last update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2.Product|Product} to exist before updating - * inventory information. If the request is valid, the update will be enqueued - * and processed downstream. As a consequence, when a response is returned, - * updates are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} has no - * effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * @param {number[]} request.localInventories - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - * @param {google.protobuf.FieldMask} request.addMask - * Indicates which inventory fields in the provided list of - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory} to update. The - * field is updated to the provided value. - * - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, the local inventory will still be processed and retained for at most - * 1 day and processed once the {@link google.cloud.retail.v2.Product|Product} is - * created. If set to false, a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.add_local_inventories.js - * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async - */ - addLocalInventories( - request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addLocalInventories( - request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.add_local_inventories.js - * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async - */ - async checkAddLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Remove local inventory information for a - * {@link google.cloud.retail.v2.Product|Product} at a list of places at a removal - * timestamp. - * - * This process is asynchronous. If the request is valid, the removal will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, removals are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} has no - * effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * @param {string[]} request.placeIds - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a - * NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.remove_local_inventories.js - * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async - */ - removeLocalInventories( - request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeLocalInventories( - request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.remove_local_inventories.js - * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async - */ - async checkRemoveLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.retail.v2.Product|Product}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of - * whether or not this branch exists, a PERMISSION_DENIED error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. - * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2.Product|Product}s sharing the same - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. - * For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product} or - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error - * is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the - * responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2.Product.name|Product.name} - * * {@link google.cloud.retail.v2.Product.id|Product.id} - * * {@link google.cloud.retail.v2.Product.title|Product.title} - * * {@link google.cloud.retail.v2.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2.Product.images|Product.images} - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no - * matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.retail.v2.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.retail.v2.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IProduct[], - protos.google.cloud.retail.v2.IListProductsRequest|null, - protos.google.cloud.retail.v2.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.retail.v2.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListProductsRequest, - protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2.IProduct>): void; - listProducts( - request: protos.google.cloud.retail.v2.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListProductsRequest, - protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2.IProduct>): void; - listProducts( - request?: protos.google.cloud.retail.v2.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2.IListProductsRequest, - protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2.IListProductsRequest, - protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2.IProduct>): - Promise<[ - protos.google.cloud.retail.v2.IProduct[], - protos.google.cloud.retail.v2.IListProductsRequest|null, - protos.google.cloud.retail.v2.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of - * whether or not this branch exists, a PERMISSION_DENIED error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. - * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2.Product|Product}s sharing the same - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. - * For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product} or - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error - * is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the - * responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2.Product.name|Product.name} - * * {@link google.cloud.retail.v2.Product.id|Product.id} - * * {@link google.cloud.retail.v2.Product.title|Product.title} - * * {@link google.cloud.retail.v2.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2.Product.images|Product.images} - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no - * matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.retail.v2.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of - * whether or not this branch exists, a PERMISSION_DENIED error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. - * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2.Product|Product}s sharing the same - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. - * For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product} or - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error - * is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the - * responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2.Product.name|Product.name} - * * {@link google.cloud.retail.v2.Product.id|Product.id} - * * {@link google.cloud.retail.v2.Product.title|Product.title} - * * {@link google.cloud.retail.v2.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2.Product.images|Product.images} - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no - * matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.retail.v2.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/product_service.list_products.js - * region_tag:retail_v2_generated_ProductService_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.retail.v2.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.productServiceStub && !this._terminated) { - return this.productServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/product_service_client_config.json b/owl-bot-staging/v2/src/v2/product_service_client_config.json deleted file mode 100644 index 32245ac6..00000000 --- a/owl-bot-staging/v2/src/v2/product_service_client_config.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.ProductService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "GetProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ListProducts": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "UpdateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "DeleteProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportProducts": { - "timeout_millis": 300000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "SetInventory": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/product_service_proto_list.json b/owl-bot-staging/v2/src/v2/product_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/product_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/search_service_client.ts b/owl-bot-staging/v2/src/v2/search_service_client.ts deleted file mode 100644 index 7303493f..00000000 --- a/owl-bot-staging/v2/src/v2/search_service_client.ts +++ /dev/null @@ -1,1243 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/search_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './search_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2 - */ -export class SearchServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - searchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SearchServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SearchServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - search: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.SearchService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.searchServiceStub) { - return this.searchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.SearchService. - this.searchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.SearchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.SearchService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const searchServiceStubMethods = - ['search']; - for (const methodName of searchServiceStubMethods) { - const callPromise = this.searchServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.searchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Performs a search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to a reasonable value. The maximum allowed value is - * 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must - * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - * error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} - * is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for - * more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it - * unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both {@link |ServingConfig.boost_control_ids} and - * [SearchRequest.boost_spec] are set, the boost conditions from both places - * are evaluated. If a search request matches multiple boost conditions, - * the final boost score is equal to the sum of the boost scores from all - * matched boost conditions. - * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s attributes, - * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The - * attributes from all the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - search( - request?: protos.google.cloud.retail.v2.ISearchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2.ISearchRequest|null, - protos.google.cloud.retail.v2.ISearchResponse - ]>; - search( - request: protos.google.cloud.retail.v2.ISearchRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2.ISearchRequest, - protos.google.cloud.retail.v2.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): void; - search( - request: protos.google.cloud.retail.v2.ISearchRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2.ISearchRequest, - protos.google.cloud.retail.v2.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): void; - search( - request?: protos.google.cloud.retail.v2.ISearchRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2.ISearchRequest, - protos.google.cloud.retail.v2.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2.SearchResponse.ISearchResult>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2.ISearchRequest, - protos.google.cloud.retail.v2.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): - Promise<[ - protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2.ISearchRequest|null, - protos.google.cloud.retail.v2.ISearchResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.search(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to a reasonable value. The maximum allowed value is - * 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must - * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - * error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} - * is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for - * more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it - * unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both {@link |ServingConfig.boost_control_ids} and - * [SearchRequest.boost_spec] are set, the boost conditions from both places - * are evaluated. If a search request matches multiple boost conditions, - * the final boost score is equal to the sum of the boost scores from all - * matched boost conditions. - * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s attributes, - * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The - * attributes from all the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - searchStream( - request?: protos.google.cloud.retail.v2.ISearchRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.createStream( - this.innerApiCalls.search as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `search`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to a reasonable value. The maximum allowed value is - * 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must - * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - * error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} - * is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for - * more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it - * unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both {@link |ServingConfig.boost_control_ids} and - * [SearchRequest.boost_spec] are set, the boost conditions from both places - * are evaluated. If a search request matches multiple boost conditions, - * the final boost score is equal to the sum of the boost scores from all - * matched boost conditions. - * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s attributes, - * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The - * attributes from all the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/search_service.search.js - * region_tag:retail_v2_generated_SearchService_Search_async - */ - searchAsync( - request?: protos.google.cloud.retail.v2.ISearchRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.asyncIterate( - this.innerApiCalls['search'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.searchServiceStub && !this._terminated) { - return this.searchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/search_service_client_config.json b/owl-bot-staging/v2/src/v2/search_service_client_config.json deleted file mode 100644 index 5132c12d..00000000 --- a/owl-bot-staging/v2/src/v2/search_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.SearchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Search": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/search_service_proto_list.json b/owl-bot-staging/v2/src/v2/search_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/search_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/user_event_service_client.ts b/owl-bot-staging/v2/src/v2/user_event_service_client.ts deleted file mode 100644 index 18b3688e..00000000 --- a/owl-bot-staging/v2/src/v2/user_event_service_client.ts +++ /dev/null @@ -1,966 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/user_event_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './user_event_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting end user actions on the customer website. - * @class - * @memberof v2 - */ -export class UserEventServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - userEventServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of UserEventServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof UserEventServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const purgeUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.PurgeUserEventsResponse') as gax.protobuf.Type; - const purgeUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.PurgeMetadata') as gax.protobuf.Type; - const importUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportUserEventsResponse') as gax.protobuf.Type; - const importUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; - const rejoinUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RejoinUserEventsResponse') as gax.protobuf.Type; - const rejoinUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RejoinUserEventsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - purgeUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), - purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), - importUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importUserEventsResponse.decode.bind(importUserEventsResponse), - importUserEventsMetadata.decode.bind(importUserEventsMetadata)), - rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), - rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.UserEventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.userEventServiceStub) { - return this.userEventServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.UserEventService. - this.userEventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.UserEventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.UserEventService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const userEventServiceStubMethods = - ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; - for (const methodName of userEventServiceStubMethods) { - const callPromise = this.userEventServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.userEventServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Writes a single user event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2.UserEvent} request.userEvent - * Required. User event to write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2.UserEvent}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.write_user_event.js - * region_tag:retail_v2_generated_UserEventService_WriteUserEvent_async - */ - writeUserEvent( - request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|undefined, {}|undefined - ]>; - writeUserEvent( - request: protos.google.cloud.retail.v2.IWriteUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request: protos.google.cloud.retail.v2.IWriteUserEventRequest, - callback: Callback< - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.writeUserEvent(request, options, callback); - } -/** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Retail API JavaScript pixel and Google Tag - * Manager. Users should not call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {string} request.userEvent - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - * @param {string} request.uri - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - * @param {number} request.ets - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.collect_user_event.js - * region_tag:retail_v2_generated_UserEventService_CollectUserEvent_async - */ - collectUserEvent( - request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|undefined, {}|undefined - ]>; - collectUserEvent( - request: protos.google.cloud.retail.v2.ICollectUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request: protos.google.cloud.retail.v2.ICollectUserEventRequest, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.collectUserEvent(request, options, callback); - } - -/** - * Deletes permanently all user events specified by the filter provided. - * Depending on the number of events specified by the filter, this operation - * could take hours or days to complete. To test a filter, use the list - * command first. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - * @param {string} request.filter - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * - * * `eventType`: Double quoted - * {@link google.cloud.retail.v2.UserEvent.event_type|UserEvent.event_type} string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * - * Examples: - * - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * - * The filtering fields are assumed to have an implicit AND. - * @param {boolean} request.force - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.purge_user_events.js - * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async - */ - purgeUserEvents( - request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeUserEvents( - request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.purgeUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.purge_user_events.js - * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async - */ - async checkPurgeUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. `projects/1234/locations/global/catalogs/default_catalog` - * @param {google.cloud.retail.v2.UserEventInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.import_user_events.js - * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async - */ - importUserEvents( - request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importUserEvents( - request: protos.google.cloud.retail.v2.IImportUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request: protos.google.cloud.retail.v2.IImportUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.import_user_events.js - * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async - */ - async checkImportUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a user event rejoin operation with latest product catalog. Events - * will not be annotated with detailed product information if product is - * missing from the catalog at the time the user event is ingested, and these - * events are stored as unjoined events with a limited usage on training and - * serving. This method can be used to start a join operation on specified - * events with latest version of product catalog. It can also be used to - * correct events joined with the wrong product catalog. A rejoin operation - * can take hours or days to complete. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js - * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async - */ - rejoinUserEvents( - request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rejoinUserEvents( - request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.rejoinUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rejoinUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js - * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async - */ - async checkRejoinUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.userEventServiceStub && !this._terminated) { - return this.userEventServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/user_event_service_client_config.json b/owl-bot-staging/v2/src/v2/user_event_service_client_config.json deleted file mode 100644 index a3938b37..00000000 --- a/owl-bot-staging/v2/src/v2/user_event_service_client_config.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.UserEventService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "WriteUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "CollectUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "PurgeUserEvents": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportUserEvents": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "RejoinUserEvents": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json b/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index ffbb2218..00000000 --- a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const retail = require('@google-cloud/retail'); - -function main() { - const catalogServiceClient = new retail.CatalogServiceClient(); - const completionServiceClient = new retail.CompletionServiceClient(); - const predictionServiceClient = new retail.PredictionServiceClient(); - const productServiceClient = new retail.ProductServiceClient(); - const searchServiceClient = new retail.SearchServiceClient(); - const userEventServiceClient = new retail.UserEventServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 285edd82..00000000 --- a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts +++ /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. ** - -import {CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient} from '@google-cloud/retail'; - -// check that the client class type name can be used -function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { - client.close(); -} -function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { - client.close(); -} -function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { - client.close(); -} -function doStuffWithProductServiceClient(client: ProductServiceClient) { - client.close(); -} -function doStuffWithSearchServiceClient(client: SearchServiceClient) { - client.close(); -} -function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const catalogServiceClient = new CatalogServiceClient(); - doStuffWithCatalogServiceClient(catalogServiceClient); - // check that the client instance can be created - const completionServiceClient = new CompletionServiceClient(); - doStuffWithCompletionServiceClient(completionServiceClient); - // check that the client instance can be created - const predictionServiceClient = new PredictionServiceClient(); - doStuffWithPredictionServiceClient(predictionServiceClient); - // check that the client instance can be created - const productServiceClient = new ProductServiceClient(); - doStuffWithProductServiceClient(productServiceClient); - // check that the client instance can be created - const searchServiceClient = new SearchServiceClient(); - doStuffWithSearchServiceClient(searchServiceClient); - // check that the client instance can be created - const userEventServiceClient = new UserEventServiceClient(); - doStuffWithUserEventServiceClient(userEventServiceClient); -} - -main(); diff --git a/owl-bot-staging/v2/system-test/install.ts b/owl-bot-staging/v2/system-test/install.ts deleted file mode 100644 index 8ec45222..00000000 --- a/owl-bot-staging/v2/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/v2/test/gapic_catalog_service_v2.ts b/owl-bot-staging/v2/test/gapic_catalog_service_v2.ts deleted file mode 100644 index 8a1bf5ac..00000000 --- a/owl-bot-staging/v2/test/gapic_catalog_service_v2.ts +++ /dev/null @@ -1,903 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as catalogserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2.CatalogServiceClient', () => { - it('has servicePath', () => { - const servicePath = catalogserviceModule.v2.CatalogServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = catalogserviceModule.v2.CatalogServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = catalogserviceModule.v2.CatalogServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new catalogserviceModule.v2.CatalogServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - await client.initialize(); - assert(client.catalogServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.catalogServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('updateCatalog', () => { - it('invokes updateCatalog without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); - const [response] = await client.updateCatalog(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCatalog( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.ICatalog|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCatalog with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCatalog(request), expectedError); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog with closed client', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCatalog(request), expectedError); - }); - }); - - describe('setDefaultBranch', () => { - it('invokes setDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.setDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setDefaultBranch( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setDefaultBranch(request), expectedError); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setDefaultBranch(request), expectedError); - }); - }); - - describe('getDefaultBranch', () => { - it('invokes getDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.getDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDefaultBranch( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IGetDefaultBranchResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDefaultBranch(request), expectedError); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDefaultBranch(request), expectedError); - }); - }); - - describe('listCatalogs', () => { - it('invokes listCatalogs without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); - const [response] = await client.listCatalogs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogs without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCatalogs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.ICatalog[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listCatalogs with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCatalogs(request), expectedError); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogsStream without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - ]; - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listCatalogsStream with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - ]; - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2.ICatalog[] = []; - const iterable = client.listCatalogsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCatalogsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2.ICatalog[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_completion_service_v2.ts b/owl-bot-staging/v2/test/gapic_completion_service_v2.ts deleted file mode 100644 index c15e5c3f..00000000 --- a/owl-bot-staging/v2/test/gapic_completion_service_v2.ts +++ /dev/null @@ -1,503 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as completionserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2.CompletionServiceClient', () => { - it('has servicePath', () => { - const servicePath = completionserviceModule.v2.CompletionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = completionserviceModule.v2.CompletionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = completionserviceModule.v2.CompletionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new completionserviceModule.v2.CompletionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - await client.initialize(); - assert(client.completionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.completionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery without error using callback', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes completeQuery with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery with closed client', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.completeQuery(request), expectedError); - }); - }); - - describe('importCompletionData', () => { - it('invokes importCompletionData without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); - const [operation] = await client.importCompletionData(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData without error using callback', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importCompletionData( - request, - (err?: Error|null, - result?: LROperation|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.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importCompletionData with call error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importCompletionData(request), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData with LRO error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importCompletionData(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportCompletionDataProgress without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportCompletionDataProgress with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts b/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts deleted file mode 100644 index efa20c2b..00000000 --- a/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as predictionserviceModule from '../src'; - -import {protobuf} 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('v2.PredictionServiceClient', () => { - it('has servicePath', () => { - const servicePath = predictionserviceModule.v2.PredictionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = predictionserviceModule.v2.PredictionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = predictionserviceModule.v2.PredictionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new predictionserviceModule.v2.PredictionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - await client.initialize(); - assert(client.predictionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.predictionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('predict', () => { - it('invokes predict without error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCall(expectedResponse); - const [response] = await client.predict(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict without error using callback', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.predict( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IPredictResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes predict with error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.predict(request), expectedError); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict with closed client', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); - request.placement = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.predict(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_product_service_v2.ts b/owl-bot-staging/v2/test/gapic_product_service_v2.ts deleted file mode 100644 index aafd946a..00000000 --- a/owl-bot-staging/v2/test/gapic_product_service_v2.ts +++ /dev/null @@ -1,1846 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as productserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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('v2.ProductServiceClient', () => { - it('has servicePath', () => { - const servicePath = productserviceModule.v2.ProductServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productserviceModule.v2.ProductServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productserviceModule.v2.ProductServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productserviceModule.v2.ProductServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productserviceModule.v2.ProductServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - await client.initialize(); - assert(client.productServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('importProducts', () => { - it('invokes importProducts without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProducts( - request, - (err?: Error|null, - result?: LROperation|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.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProducts with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProducts(request), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductsProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductsProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInventory', () => { - it('invokes setInventory without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInventory(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInventory( - request, - (err?: Error|null, - result?: LROperation|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.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setInventory with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInventory(request), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInventory(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkSetInventoryProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInventoryProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInventoryProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addFulfillmentPlaces', () => { - it('invokes addFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeFulfillmentPlaces', () => { - it('invokes removeFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addLocalInventories', () => { - it('invokes addLocalInventories without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.addLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addLocalInventories with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addLocalInventories(request), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeLocalInventories', () => { - it('invokes removeLocalInventories without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeLocalInventories with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeLocalInventories(request), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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.retail.v2.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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.retail.v2.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_search_service_v2.ts b/owl-bot-staging/v2/test/gapic_search_service_v2.ts deleted file mode 100644 index 44857ae4..00000000 --- a/owl-bot-staging/v2/test/gapic_search_service_v2.ts +++ /dev/null @@ -1,570 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as searchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2.SearchServiceClient', () => { - it('has servicePath', () => { - const servicePath = searchserviceModule.v2.SearchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = searchserviceModule.v2.SearchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = searchserviceModule.v2.SearchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new searchserviceModule.v2.SearchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - await client.initialize(); - assert(client.searchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.searchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('search', () => { - it('invokes search without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCall(expectedResponse); - const [response] = await client.search(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes search without error using callback', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.search( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes search with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchStream without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes searchStream with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedError = new Error('expected'); - client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = []; - const iterable = client.searchAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts b/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts deleted file mode 100644 index 2cb56664..00000000 --- a/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts +++ /dev/null @@ -1,888 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as usereventserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2.UserEventServiceClient', () => { - it('has servicePath', () => { - const servicePath = usereventserviceModule.v2.UserEventServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = usereventserviceModule.v2.UserEventServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = usereventserviceModule.v2.UserEventServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new usereventserviceModule.v2.UserEventServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - await client.initialize(); - assert(client.userEventServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.userEventServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('writeUserEvent', () => { - it('invokes writeUserEvent without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.writeUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.writeUserEvent( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IUserEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes writeUserEvent with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.writeUserEvent(request), expectedError); - }); - }); - - describe('collectUserEvent', () => { - it('invokes collectUserEvent without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.collectUserEvent( - request, - (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes collectUserEvent with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.collectUserEvent(request), expectedError); - }); - }); - - describe('purgeUserEvents', () => { - it('invokes purgeUserEvents without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeUserEvents with call error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeUserEvents(request), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importUserEvents', () => { - it('invokes importUserEvents without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.importUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importUserEvents with call error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rejoinUserEvents', () => { - it('invokes rejoinUserEvents without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejoinUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejoinUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes rejoinUserEvents with call error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejoinUserEvents(request), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejoinUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRejoinUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRejoinUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/tsconfig.json b/owl-bot-staging/v2/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v2/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/v2/webpack.config.js b/owl-bot-staging/v2/webpack.config.js deleted file mode 100644 index f2c58f25..00000000 --- a/owl-bot-staging/v2/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: 'CatalogService', - filename: './catalog-service.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v2alpha/.eslintignore b/owl-bot-staging/v2alpha/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v2alpha/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v2alpha/.eslintrc.json b/owl-bot-staging/v2alpha/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v2alpha/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v2alpha/.gitignore b/owl-bot-staging/v2alpha/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v2alpha/.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/v2alpha/.jsdoc.js b/owl-bot-staging/v2alpha/.jsdoc.js deleted file mode 100644 index 19729810..00000000 --- a/owl-bot-staging/v2alpha/.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/retail', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v2alpha/.mocharc.js b/owl-bot-staging/v2alpha/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v2alpha/.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/v2alpha/.prettierrc.js b/owl-bot-staging/v2alpha/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v2alpha/.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/v2alpha/README.md b/owl-bot-staging/v2alpha/README.md deleted file mode 100644 index 822c4573..00000000 --- a/owl-bot-staging/v2alpha/README.md +++ /dev/null @@ -1 +0,0 @@ -Retail: Nodejs Client diff --git a/owl-bot-staging/v2alpha/linkinator.config.json b/owl-bot-staging/v2alpha/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v2alpha/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/v2alpha/package.json b/owl-bot-staging/v2alpha/package.json deleted file mode 100644 index 94071ee3..00000000 --- a/owl-bot-staging/v2alpha/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@google-cloud/retail", - "version": "0.1.0", - "description": "Retail client for Node.js", - "repository": "googleapis/nodejs-retail", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google retail", - "retail", - "catalog service", - "completion service", - "control service", - "prediction service", - "product service", - "search service", - "serving config service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto deleted file mode 100644 index 9b3d8cb0..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/import_config.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Configures what level the product should be uploaded with regards to -// how users will be send events and how predictions will be made. -message ProductLevelConfig { - // The type of [Product][google.cloud.retail.v2alpha.Product]s allowed to be - // ingested into the catalog. Acceptable values are: - // - // * `primary` (default): You can ingest - // [Product][google.cloud.retail.v2alpha.Product]s of all types. When - // ingesting a [Product][google.cloud.retail.v2alpha.Product], its type will - // default to - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // if unset. - // * `variant`: You can only ingest - // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s. - // This means - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] - // cannot be empty. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `variant` and - // [merchant_center_product_id_field][google.cloud.retail.v2alpha.ProductLevelConfig.merchant_center_product_id_field] - // is `itemGroupId`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string ingestion_product_type = 1; - - // Which field of [Merchant Center - // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be - // imported as [Product.id][google.cloud.retail.v2alpha.Product.id]. - // Acceptable values are: - // - // * `offerId` (default): Import `offerId` as the product ID. - // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail - // API will choose one item from the ones with the same `itemGroupId`, and - // use it to represent the item group. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `itemGroupId` and - // [ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] - // is `variant`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string merchant_center_product_id_field = 2; -} - -// Catalog level attribute config for an attribute. For example, if customers -// want to enable/disable facet for a specific attribute. -message CatalogAttribute { - // The type of an attribute. - enum AttributeType { - // The type of the attribute is unknown. - // - // Used when type cannot be derived from attribute that is not - // [in_use][google.cloud.retail.v2alpha.CatalogAttribute.in_use]. - UNKNOWN = 0; - - // Textual attribute. - TEXTUAL = 1; - - // Numerical attribute. - NUMERICAL = 2; - } - - // The status of the indexable option of a catalog attribute. - enum IndexableOption { - // Value used when unset. Defaults to - // [INDEXABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. - INDEXABLE_OPTION_UNSPECIFIED = 0; - - // Indexable option enabled for an attribute. - INDEXABLE_ENABLED = 1; - - // Indexable option disabled for an attribute. - INDEXABLE_DISABLED = 2; - } - - // The status of the dynamic facetable option of a catalog attribute. - enum DynamicFacetableOption { - // Value used when unset. Defaults to - // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. - DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; - - // Dynamic facetable option enabled for an attribute. - DYNAMIC_FACETABLE_ENABLED = 1; - - // Dynamic facetable option disabled for an attribute. - DYNAMIC_FACETABLE_DISABLED = 2; - } - - // The status of the searchable option of a catalog attribute. - enum SearchableOption { - // Value used when unset. Defaults to - // [SEARCHABLE_DISABLED][google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. - SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Searchable option enabled for an attribute. - SEARCHABLE_ENABLED = 1; - - // Searchable option disabled for an attribute. - SEARCHABLE_DISABLED = 2; - } - - // Required. Attribute name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Output only. Indicates whether this attribute has been used by any - // products. `True` if at least one - // [Product][google.cloud.retail.v2alpha.Product] is using this attribute in - // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. - // Otherwise, this field is `False`. - // - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] can be - // pre-loaded by using [AddCatalogAttribute][], [ImportCatalogAttributes][], - // or [UpdateAttributesConfig][] APIs. This field is `False` for pre-loaded - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s. - // - // Only [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that - // are not in use by products can be deleted. - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that are - // in use by products cannot be deleted; however, their configuration - // properties will reset to default values upon removal request. - // - // After catalog changes, it takes about 10 minutes for this field to update. - bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The type of this attribute. This is derived from the attribute - // in [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. - AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values - // are indexed so that it can be filtered, faceted, or boosted in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - IndexableOption indexable_option = 5; - - // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic - // facet. Could only be DYNAMIC_FACETABLE_DISABLED if - // [CatalogAttribute.indexable_option][google.cloud.retail.v2alpha.CatalogAttribute.indexable_option] - // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. - DynamicFacetableOption dynamic_facetable_option = 6; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values - // are searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values - // will not be searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], - // as there are no text values associated to numerical attributes. - SearchableOption searchable_option = 7; -} - -// Catalog level attribute config. -message AttributesConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/AttributesConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" - }; - - // Required. Immutable. The fully qualified resource name of the attribute - // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Enable attribute(s) config at catalog level. - // For example, indexable, dynamic_facetable, or searchable for each - // attribute. - // - // The key is catalog attribute's name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - // - // The maximum number of catalog attributes allowed in a request is 1000. - map catalog_attributes = 2; - - // Output only. The - // [AttributeConfigLevel][google.cloud.retail.v2alpha.AttributeConfigLevel] - // used for this catalog. - AttributeConfigLevel attribute_config_level = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Catalog level autocomplete config for customers to customize autocomplete -// feature's settings. -message CompletionConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/CompletionConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" - }; - - // Required. Immutable. Fully qualified name - // `projects/*/locations/*/catalogs/*/completionConfig` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Specifies the matching order for autocomplete suggestions, e.g., a query - // consisting of 'sh' with 'out-of-order' specified would suggest "women's - // shoes", whereas a query of 'red s' with 'exact-prefix' specified would - // suggest "red shoes". Currently supported values: - // - // * 'out-of-order' - // * 'exact-prefix' - // - // Default value: 'exact-prefix'. - string matching_order = 2; - - // The maximum number of autocomplete suggestions returned per term. The - // maximum allowed max suggestions is 20. Default value is 20. If left unset - // or set to 0, then will fallback to default value. - int32 max_suggestions = 3; - - // The minimum number of characters needed to be typed in order to get - // suggestions. Default value is 2. If left unset or set to 0, then will - // fallback to default value. - int32 min_prefix_length = 4; - - // If set to true, the auto learning function is enabled. Auto learning uses - // user data to generate suggestions using ML techniques. Default value is - // false. Only after enabling auto learning can users use `cloud-retail` - // data in - // [CompleteQueryRequest][google.cloud.retail.v2alpha.CompleteQueryRequest]. - bool auto_learning = 11; - - // Output only. The input config for the import of the source data that - // contains the autocomplete phrases uploaded by the customer. - CompletionDataInputConfig suggestions_input_config = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the LRO corresponding to the latest suggestion terms - // list import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_suggestions_import_operation = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The input config for the import of the source data that - // contains the / autocomplete denylist phrases uploaded by the customer. - CompletionDataInputConfig denylist_input_config = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. LRO corresponding to the latest denylist import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_denylist_import_operation = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The input config for the import of the source data that - // contains the autocomplete allowlist phrases uploaded by the customer. - CompletionDataInputConfig allowlist_input_config = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. LRO corresponding to the latest allowlist import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_allowlist_import_operation = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Represents a link between a Merchant Center account and a branch. -// Once a link is established, products from the linked merchant center account -// will be streamed to the linked branch. -message MerchantCenterLink { - // Required. The linked [Merchant center account - // id](https://developers.google.com/shopping-content/guides/accountstatuses). - // The account must be a standalone account or a sub-account of a MCA. - int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch id (e.g. 0/1/2) within this catalog that products from - // merchant_center_account_id are streamed to. When updating this field, an - // empty value will use the currently configured default branch. However, - // changing the default branch later on won't change the linked branch here. - // - // A single branch id can only have one linked merchant center account id. - string branch_id = 2; - - // String representing the destination to import for, all if left empty. - // List of possible values can be found here. - // [https://support.google.com/merchants/answer/7501026] - // List of allowed string values: - // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory - // _ads", "Free_listings", "Free_local_listings" - // NOTE: The string values are case sensitive. - repeated string destinations = 3; - - // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 - // code. List of values can be found - // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) - // under the `region` tag. If left blank no region filtering will be - // performed. - // - // Example value: `US`. - string region_code = 4; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // ISO 639-1. - // - // This specifies the language of offers in Merchant Center that will be - // accepted. If empty no language filtering will be performed. - // - // Example value: `en`. - string language_code = 5; -} - -// Configures Merchant Center linking. -// Links contained in the config will be used to sync data from a Merchant -// Center account to a Cloud Retail branch. -message MerchantCenterLinkingConfig { - // Links between Merchant Center accounts and branches. - repeated MerchantCenterLink links = 1; -} - -// The catalog configuration. -message Catalog { - option (google.api.resource) = { - type: "retail.googleapis.com/Catalog" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" - }; - - // Required. Immutable. The fully qualified resource name of the catalog. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. Immutable. The catalog display name. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. The product level configuration. - ProductLevelConfig product_level_config = 4 - [(google.api.field_behavior) = REQUIRED]; - - // The Merchant Center linking configuration. - // Once a link is added, the data stream from Merchant Center to Cloud Retail - // will be enabled automatically. The requester must have access to the - // merchant center account in order to make changes to this field. - MerchantCenterLinkingConfig merchant_center_linking_config = 6; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto deleted file mode 100644 index 6ecab725..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto +++ /dev/null @@ -1,478 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/catalog.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for managing catalog configuration. -service CatalogService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated - // with the project. - rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*}/catalogs" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s. - rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { - option (google.api.http) = { - patch: "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}" - body: "catalog" - }; - option (google.api.method_signature) = "catalog,update_mask"; - } - - // Set a specified branch id as default branch. API methods such as - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] - // will treat requests using "default_branch" to the actual branch id set as - // default. - // - // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as - // default, setting - // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent - // to setting - // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/1`. - // - // Using multiple branches can be useful when developers would like - // to have a staging branch to test and verify for future usage. When it - // becomes ready, developers switch on the staging branch using this API while - // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` - // as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] - // to route the traffic to this staging branch. - // - // CAUTION: If you have live predict/search traffic, switching the default - // branch could potentially cause outages if the ID space of the new branch is - // very different from the old one. - // - // More specifically: - // - // * PredictionService will only return product IDs from branch {newBranch}. - // * SearchService will only return product IDs from branch {newBranch} - // (if branch is not explicitly set). - // * UserEventService will only join events with products from branch - // {newBranch}. - rpc SetDefaultBranch(SetDefaultBranchRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" - body: "*" - }; - option (google.api.method_signature) = "catalog"; - } - - // Get which branch is currently default branch set by - // [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] - // method under a specified parent catalog. - rpc GetDefaultBranch(GetDefaultBranchRequest) - returns (GetDefaultBranchResponse) { - option (google.api.http) = { - get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" - }; - option (google.api.method_signature) = "catalog"; - } - - // Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]. - rpc GetCompletionConfig(GetCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/completionConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the - // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s. - rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - patch: "/v2alpha/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" - body: "completion_config" - }; - option (google.api.method_signature) = "completion_config,update_mask"; - } - - // Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. - rpc GetAttributesConfig(GetAttributesConfigRequest) - returns (AttributesConfig) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/attributesConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. - // - // The catalog attributes in the request will be updated in the catalog, or - // inserted if they do not exist. Existing catalog attributes not included in - // the request will remain unchanged. Attributes that are assigned to - // products, but do not exist at the catalog level, are always included in the - // response. The product attribute is assigned default values for missing - // catalog attribute fields, e.g., searchable and dynamic facetable options. - rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) - returns (AttributesConfig) { - option (google.api.http) = { - patch: "/v2alpha/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" - body: "attributes_config" - }; - option (google.api.method_signature) = "attributes_config,update_mask"; - } - - // Adds the specified - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to - // add already exists, an ALREADY_EXISTS error is returned. - rpc AddCatalogAttribute(AddCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" - body: "*" - }; - } - - // Removes the specified - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to - // remove does not exist, a NOT_FOUND error is returned. - rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" - body: "*" - }; - } - - // Replaces the specified - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by - // updating the catalog attribute with the same - // [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. - // - // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to - // replace does not exist, a NOT_FOUND error is returned. - rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" - body: "*" - }; - } -} - -// Request for -// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] -// method. -message ListCatalogsRequest { - // Required. The account resource name with an associated location. - // - // If the caller does not have permission to list - // [Catalog][google.cloud.retail.v2alpha.Catalog]s under this location, - // regardless of whether or not this location exists, a PERMISSION_DENIED - // error is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of [Catalog][google.cloud.retail.v2alpha.Catalog]s to - // return. If unspecified, defaults to 50. The maximum allowed value is 1000. - // Values above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 2; - - // A page token - // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token], - // received from a previous - // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; -} - -// Response for -// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] -// method. -message ListCatalogsResponse { - // All the customer's [Catalog][google.cloud.retail.v2alpha.Catalog]s. - repeated Catalog catalogs = 1; - - // A token that can be sent as - // [ListCatalogsRequest.page_token][google.cloud.retail.v2alpha.ListCatalogsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request for -// [CatalogService.UpdateCatalog][google.cloud.retail.v2alpha.CatalogService.UpdateCatalog] -// method. -message UpdateCatalogRequest { - // Required. The [Catalog][google.cloud.retail.v2alpha.Catalog] to update. - // - // If the caller does not have permission to update the - // [Catalog][google.cloud.retail.v2alpha.Catalog], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Catalog][google.cloud.retail.v2alpha.Catalog] to update does not - // exist, a NOT_FOUND error is returned. - Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Catalog][google.cloud.retail.v2alpha.Catalog] to update. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message to set a specified branch as new default_branch. -message SetDefaultBranchRequest { - // Full resource name of the catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // The final component of the resource name of a branch. - // - // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - // error is returned. - // - // If there are no sufficient active products in the targeted branch and - // [force][google.cloud.retail.v2alpha.SetDefaultBranchRequest.force] is not - // set, a FAILED_PRECONDITION error is returned. - string branch_id = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Some note on this request, this can be retrieved by - // [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch] - // before next valid default branch set occurs. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string note = 3; - - // If set to true, it permits switching to a branch with - // [branch_id][google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id] - // even if it has no sufficient active products. - bool force = 4; -} - -// Request message to show which branch is currently the default branch. -message GetDefaultBranchRequest { - // The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; -} - -// Response message of -// [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch]. -message GetDefaultBranchResponse { - // Full resource name of the branch id currently set as default branch. - string branch = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // The time when this branch is set to default. - google.protobuf.Timestamp set_time = 2; - - // This corresponds to - // [SetDefaultBranchRequest.note][google.cloud.retail.v2alpha.SetDefaultBranchRequest.note] - // field, when this branch was set as default. - string note = 3; -} - -// Request for -// [CatalogService.GetCompletionConfig][google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig] -// method. -message GetCompletionConfigRequest { - // Required. Full CompletionConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/CompletionConfig" - } - ]; -} - -// Request for -// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig] -// method. -message UpdateCompletionConfigRequest { - // Required. The - // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. - // - // If the caller does not have permission to update the - // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig], then a - // PERMISSION_DENIED error is returned. - // - // If the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to - // update does not exist, a NOT_FOUND error is returned. - CompletionConfig completion_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. - // The following are the only supported fields: - // - // * [CompletionConfig.matching_order][google.cloud.retail.v2alpha.CompletionConfig.matching_order] - // * [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions] - // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length] - // * [CompletionConfig.auto_learning][google.cloud.retail.v2alpha.CompletionConfig.auto_learning] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.GetAttributesConfig][google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig] -// method. -message GetAttributesConfigRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; -} - -// Request for -// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig] -// method. -message UpdateAttributesConfigRequest { - // Required. The - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. - AttributesConfig attributes_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. - // The following is the only supported field: - // - // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute] -// method. -message AddCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute] -// method. -message RemoveCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The attribute name key of the - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove. - string key = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute] -// method. -message ReplaceCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The updated - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to update. - // The following are NOT supported: - // - // * [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 3; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto deleted file mode 100644 index ae33d3f6..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto +++ /dev/null @@ -1,761 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// At which level we offer configuration for attributes. -enum AttributeConfigLevel { - // Value used when unset. Defaults to - // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2alpha.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. - ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; - - // At this level, we honor the attribute configurations set in - // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. - PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; - - // At this level, we honor the attribute configurations set in - // [CatalogConfig.attribute_configs][google.cloud.retail.v2alpha.CatalogConfig.attribute_configs]. - CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; -} - -// The type of solution. -enum SolutionType { - // Default value. - SOLUTION_TYPE_UNSPECIFIED = 0; - - // Used for Recommendations AI. - SOLUTION_TYPE_RECOMMENDATION = 1; - - // Used for Retail Search. - SOLUTION_TYPE_SEARCH = 2; -} - -// The use case of Cloud Retail Search. -enum SearchSolutionUseCase { - // The value when it's unspecified. Defaults to - // [SEARCH][]. - SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; - - // Search use case. Expects the traffic has a non-empty - // [query][google.cloud.retail.v2alpha.SearchRequest.query]. - SEARCH_SOLUTION_USE_CASE_SEARCH = 1; - - // Browse use case. Expects the traffic has an empty - // [query][google.cloud.retail.v2alpha.SearchRequest.query]. - SEARCH_SOLUTION_USE_CASE_BROWSE = 2; -} - -// Metadata that is used to define a condition that triggers an action. -// A valid condition must specify at least one of 'query_terms' or -// 'products_filter'. If multiple fields are specified, the condition is met if -// all the fields are satisfied e.g. if a set of query terms and product_filter -// are set, then only items matching the product_filter for requests with a -// query matching the query terms wil get boosted. -message Condition { - // Query terms that we want to match on. - message QueryTerm { - // The value of the term to match on. - // Value cannot be empty. - // Value can have at most 3 terms if specified as a partial match. Each - // space separated string is considered as one term. - // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not - // allowed for partial match. - string value = 1; - - // Whether this is supposed to be a full or partial match. - bool full_match = 2; - } - - // Used for time-dependent conditions. - // Example: Want to have rule applied for week long sale. - message TimeRange { - // Start of time range. Range is inclusive. - google.protobuf.Timestamp start_time = 1; - - // End of time range. Range is inclusive. - google.protobuf.Timestamp end_time = 2; - } - - // A list (up to 10 entries) of terms to match the query on. If not - // specified, match all queries. - // If many query terms are specified, the condition - // is matched if any of the terms is a match (i.e. using the OR operator). - repeated QueryTerm query_terms = 1; - - // Range of time(s) specifying when Condition is active. - // Condition true if any time range matches. - repeated TimeRange active_time_range = 3; -} - -// A rule is a condition-action pair -// * A condition defines when a rule is to be triggered. -// * An action specifies what occurs on that trigger. -// Currently only boost rules are supported. -// Currently only supported by the search endpoint. -message Rule { - // A boost action to apply to results matching condition specified above. - message BoostAction { - // Strength of the condition boost, which must be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 1; - - // The filter can have a max size of 5000 characters. - // An expression which specifies which products to apply an action to. - // The syntax and supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue":
- // *(id: ANY("product_1", "product_2"))
* - // *AND
* - // *(colorFamilies: ANY("Red", "Blue"))
* - string products_filter = 2; - } - - // * Rule Condition: - // - No [Condition][query_terms] provided is a global match. - // - 1 or more [Condition][query_terms] provided is combined with OR - // operator. - // * Action Input: The request query and filter that will be applied to the - // retrieved products, in addition to any filters already provided with the - // SearchRequest. The AND operator is used to combine the query's existing - // filters with the filter rule(s). NOTE: May result in 0 results when - // filters conflict. - // * Action Result: Filters the returned objects to be ONLY those that passed - // the filter. - message FilterAction { - // A filter to apply on the matching condition results. Supported features: - // - // * [filter][google.cloud.retail.v2alpha.Rule.FilterAction.filter] must be - // set. - // * Filter syntax is identical to - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]. - // See more - // details at the Retail Search - // [user guide](/retail/search/docs/filter-and-order#filter). - // * To filter products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue":
- // *(id: ANY("product_1", "product_2"))
* - // *AND
* - // *(colorFamilies: ANY("Red", "Blue"))
* - string filter = 1; - } - - // Redirects a shopper to a specific page. - // * Rule Condition: - // - Must specify [Condition][query_terms]. - // * Action Input: Request Query - // * Action Result: Redirects shopper to provided uri. - message RedirectAction { - // URL must have length equal or less than 2000 characters. - string redirect_uri = 1; - } - - // Creates a set of terms that will be treated as synonyms of each other. - // Example: synonyms of "sneakers" and "shoes". - // * "sneakers" will use a synonym of "shoes". - // * "shoes" will use a synonym of "sneakers". - message TwowaySynonymsAction { - // Defines a set of synonyms. - // Can specify up to 100 synonyms. - // Must specify at least 2 synonyms. - repeated string synonyms = 1; - } - - // Maps a set of terms to a set of synonyms. - // Set of synonyms will be treated as synonyms of each query term only. - // `query_terms` will not be treated as synonyms of each other. - // Example: "sneakers" will use a synonym of "shoes". - // "shoes" will not use a synonym of "sneakers". - message OnewaySynonymsAction { - // Terms from the search query. - // Will treat synonyms as their synonyms. - // Not themselves synonyms of the synonyms. - // Can specify up to 100 terms. - repeated string query_terms = 3; - - // Defines a set of synonyms. - // Cannot contain duplicates. - // Can specify up to 100 synonyms. - repeated string synonyms = 4; - - // Will be [deprecated = true] post migration; - repeated string oneway_terms = 2; - } - - // Prevents `query_term` from being associated with specified terms during - // search. - // Example: Don't associate "gShoe" and "cheap". - message DoNotAssociateAction { - // Terms from the search query. - // Will not consider do_not_associate_terms for search if in search query. - // Can specify up to 100 terms. - repeated string query_terms = 2; - - // Cannot contain duplicates or the query term. - // Can specify up to 100 terms. - repeated string do_not_associate_terms = 3; - - // Will be [deprecated = true] post migration; - repeated string terms = 1; - } - - // Replaces a term in the query. Multiple replacement candidates can be - // specified. All `query_terms` will be replaced with the replacement term. - // Example: Replace "gShoe" with "google shoe". - message ReplacementAction { - // Terms from the search query. - // Will be replaced by replacement term. - // Can specify up to 100 terms. - repeated string query_terms = 2; - - // Term that will be used for replacement. - string replacement_term = 3; - - // Will be [deprecated = true] post migration; - string term = 1; - } - - // Prevents a term in the query from being used in search. - // Example: Don't search for "shoddy". - message IgnoreAction { - // Terms to ignore in the search query. - repeated string ignore_terms = 1; - } - - // An action must be provided. - oneof action { - // A boost action. - BoostAction boost_action = 2; - - // Redirects a shopper to a specific page. - RedirectAction redirect_action = 3; - - // Treats specific term as a synonym with a group of terms. - // Group of terms will not be treated as synonyms with the specific term. - OnewaySynonymsAction oneway_synonyms_action = 6; - - // Prevents term from being associated with other terms. - DoNotAssociateAction do_not_associate_action = 7; - - // Replaces specific terms in the query. - ReplacementAction replacement_action = 8; - - // Ignores specific terms from query during search. - IgnoreAction ignore_action = 9; - - // Filters results. - FilterAction filter_action = 10; - - // Treats a set of terms as synonyms of one another. - TwowaySynonymsAction twoway_synonyms_action = 11; - } - - // Required. The condition that triggers the rule. - // If the condition is empty, the rule will always apply. - Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// An intended audience of the [Product][google.cloud.retail.v2alpha.Product] -// for whom it's sold. -message Audience { - // The genders of the audience. Strongly encouraged to use the standard - // values: "male", "female", "unisex". - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [gender](https://support.google.com/merchants/answer/6324479). Schema.org - // property - // [Product.audience.suggestedGender](https://schema.org/suggestedGender). - repeated string genders = 1; - - // The age groups of the audience. Strongly encouraged to use the standard - // values: "newborn" (up to 3 months old), "infant" (3–12 months old), - // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically - // teens or older). - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [age_group](https://support.google.com/merchants/answer/6324463). - // Schema.org property - // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and - // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). - repeated string age_groups = 2; -} - -// The color information of a [Product][google.cloud.retail.v2alpha.Product]. -message ColorInfo { - // The standard color families. Strongly recommended to use the following - // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", - // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and - // "Mixed". Normally it is expected to have only 1 color family. May consider - // using single "Mixed" instead of multiple values. - // - // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string color_families = 1; - - // The color display names, which may be different from standard color family - // names, such as the color aliases used in the website frontend. Normally - // it is expected to have only 1 color. May consider using single "Mixed" - // instead of multiple values. - // - // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string colors = 2; -} - -// A custom attribute that is not explicitly modeled in -// [Product][google.cloud.retail.v2alpha.Product]. -message CustomAttribute { - // The textual values of this custom attribute. For example, `["yellow", - // "green"]` when the key is "color". - // - // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be - // set. Otherwise, an INVALID_ARGUMENT error is returned. - repeated string text = 1; - - // The numerical values of this custom attribute. For example, `[2.3, 15.4]` - // when the key is "lengths_cm". - // - // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be - // set. Otherwise, an INVALID_ARGUMENT error is returned. - repeated double numbers = 2; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // This field is ignored in a - // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. - // - // Only set if type [text][google.cloud.retail.v2alpha.CustomAttribute.text] - // is set. Otherwise, a INVALID_ARGUMENT error is returned. - optional bool searchable = 3; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // indexed, so that it can be filtered, faceted or boosted in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // This field is ignored in a - // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. - // - // See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter], - // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] - // and - // [SearchRequest.boost_spec][google.cloud.retail.v2alpha.SearchRequest.boost_spec] - // for more details. - optional bool indexable = 4; -} - -// Fulfillment information, such as the store IDs for in-store pickup or region -// IDs for different shipping methods. -message FulfillmentInfo { - // The fulfillment type, including commonly used types (such as pickup in - // store and same day delivery), and custom types. Customers have to map - // custom types to their display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - string type = 1; - - // The IDs for this [type][google.cloud.retail.v2alpha.FulfillmentInfo.type], - // such as the store IDs for - // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // or the region IDs for - // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2alpha.FulfillmentInfo.type]. - // - // A maximum of 3000 values are allowed. Each value must be a string with a - // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such - // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string place_ids = 2; -} - -// [Product][google.cloud.retail.v2alpha.Product] image. Recommendations AI and -// Retail Search do not use product images to improve prediction and search -// results. However, product images can be returned in results, and are shown in -// prediction or search previews in the console. -message Image { - // Required. URI of the image. - // - // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // Height of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 height = 2; - - // Width of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 width = 3; -} - -// A floating point interval. -message Interval { - // The lower bound of the interval. If neither of the min fields are set, then - // the lower bound is negative infinity. - // - // This field must be not larger than - // [max][google.cloud.retail.v2alpha.Interval.max]. Otherwise, an - // INVALID_ARGUMENT error is returned. - oneof min { - // Inclusive lower bound. - double minimum = 1; - - // Exclusive lower bound. - double exclusive_minimum = 2; - } - - // The upper bound of the interval. If neither of the max fields are set, then - // the upper bound is positive infinity. - // - // This field must be not smaller than - // [min][google.cloud.retail.v2alpha.Interval.min]. Otherwise, an - // INVALID_ARGUMENT error is returned. - oneof max { - // Inclusive upper bound. - double maximum = 3; - - // Exclusive upper bound. - double exclusive_maximum = 4; - } -} - -// The price information of a [Product][google.cloud.retail.v2alpha.Product]. -message PriceInfo { - // The price range of all - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. - message PriceRange { - // The inclusive - // [Product.pricing_info.price][google.cloud.retail.v2alpha.PriceInfo.price] - // interval of all - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. - Interval price = 1; - - // The inclusive - // [Product.pricing_info.original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] - // internal of all - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. - Interval original_price = 2; - } - - // The 3-letter currency code defined in [ISO - // 4217](https://www.iso.org/iso-4217-currency-codes.html). - // - // If this field is an unrecognizable currency code, an INVALID_ARGUMENT - // error is returned. - // - // The - // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s with the same - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] - // must share the same - // [currency_code][google.cloud.retail.v2alpha.PriceInfo.currency_code]. - // Otherwise, a FAILED_PRECONDITION error is returned. - string currency_code = 1; - - // Price of the product. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). Schema.org - // property [Offer.price](https://schema.org/price). - float price = 2; - - // Price of the product without any discount. If zero, by default set to be - // the [price][google.cloud.retail.v2alpha.PriceInfo.price]. - float original_price = 3; - - // The costs associated with the sale of a particular product. Used for gross - // profit reporting. - // - // * Profit = [price][google.cloud.retail.v2alpha.PriceInfo.price] - - // [cost][google.cloud.retail.v2alpha.PriceInfo.cost] - // - // Google Merchant Center property - // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). - float cost = 4; - - // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] - // starts to be effective. This can be set as a future timestamp, and the - // [price][google.cloud.retail.v2alpha.PriceInfo.price] is only used for - // search after - // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. - // If so, the - // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must - // be set and - // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is - // used before - // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. - // - // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is - // always effective because it will cause additional latency during search. - google.protobuf.Timestamp price_effective_time = 5; - - // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] - // stops to be effective. The - // [price][google.cloud.retail.v2alpha.PriceInfo.price] is used for search - // before - // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. - // If this field is set, the - // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must - // be set and - // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is - // used after - // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. - // - // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is - // always effective because it will cause additional latency during search. - google.protobuf.Timestamp price_expire_time = 6; - - // Output only. The price range of all the child - // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s grouped together on the - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]. Only populated for - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. - // Do not set this field in API requests. - PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The rating of a [Product][google.cloud.retail.v2alpha.Product]. -message Rating { - // The total number of ratings. This value is independent of the value of - // [rating_histogram][google.cloud.retail.v2alpha.Rating.rating_histogram]. - // - // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 rating_count = 1; - - // The average rating of the [Product][google.cloud.retail.v2alpha.Product]. - // - // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is - // returned. - float average_rating = 2; - - // List of rating counts per rating value (index = rating - 1). The list is - // empty if there is no rating. If the list is non-empty, its size is - // always 5. Otherwise, an INVALID_ARGUMENT error is returned. - // - // For example, [41, 14, 13, 47, 303]. It means that the - // [Product][google.cloud.retail.v2alpha.Product] got 41 ratings with 1 star, - // 14 ratings with 2 star, and so on. - repeated int32 rating_histogram = 3; -} - -// Information of an end user. -message UserInfo { - // Highly recommended for logged-in users. Unique identifier for logged-in - // user, such as a user name. - // - // Always use a hashed value for this ID. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string user_id = 1; - - // The end user's IP address. This field is used to extract location - // information for personalization. - // - // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 - // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This should not be set when: - // - // * setting - // [SearchRequest.user_info][google.cloud.retail.v2alpha.SearchRequest.user_info]. - // * using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] - // is set. - string ip_address = 2; - - // User agent as included in the HTTP header. Required for getting - // [SearchResponse.sponsored_results][google.cloud.retail.v2alpha.SearchResponse.sponsored_results]. - // - // The field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This should not be set when using the client side event reporting with - // GTM or JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] - // is set. - string user_agent = 3; - - // True if the request is made directly from the end user, in which case the - // [ip_address][google.cloud.retail.v2alpha.UserInfo.ip_address] and - // [user_agent][google.cloud.retail.v2alpha.UserInfo.user_agent] can be - // populated from the HTTP request. This flag should be set only if the API - // request is made directly from the end user such as a mobile app (and not if - // a gateway or a server is processing and pushing the user events). - // - // This should not be set when using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent]. - bool direct_user_request = 4; -} - -// The inventory information at a place (e.g. a store) identified -// by a place ID. -message LocalInventory { - // The place ID for the current set of inventory information. - string place_id = 1; - - // Product price and cost information. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 2; - - // Additional local inventory attributes, for example, store name, promotion - // tags, etc. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * At most 30 attributes are allowed. - // * The key must be a UTF-8 encoded string with a length limit of 32 - // characters. - // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, - // key0LikeThis or KEY_1_LIKE_THIS. - // * The attribute values must be of the same type (text or number). - // * Only 1 value is allowed for each attribute. - // * For text values, the length limit is 256 UTF-8 characters. - // * The attribute does not support search. The `searchable` field should be - // unset or set to false. - // * The max summed total bytes of custom attribute keys and values per - // product is 5MiB. - map attributes = 3; - - // Input only. Supported fulfillment types. Valid fulfillment type values - // include commonly used types (such as pickup in store and same day - // delivery), and custom types. Customers have to map custom types to their - // display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string fulfillment_types = 4 - [(google.api.field_behavior) = INPUT_ONLY]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto deleted file mode 100644 index a91aa618..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/import_config.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "CompletionServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Auto-completion service for retail. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service CompletionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Completes the specified prefix with keyword suggestions. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { - option (google.api.http) = { - get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" - }; - } - - // Bulk import of processed completion dataset. - // - // Request processing is asynchronous. Partial updating is not supported. - // - // The operation is successfully finished only after the imported suggestions - // are indexed successfully and ready for serving. The process takes hours. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc ImportCompletionData(ImportCompletionDataRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/completionData:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.ImportCompletionDataResponse" - metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" - }; - } -} - -// Auto-complete parameters. -message CompleteQueryRequest { - // Required. Catalog for which the completion is performed. - // - // Full resource name of catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The query used to generate suggestions. - // - // The maximum number of allowed characters is 255. - string query = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required field. A unique identifier for tracking visitors. For example, - // this could be implemented with an HTTP cookie, which should be able to - // uniquely identify a visitor on a single device. This unique identifier - // should not change if the visitor logs in or out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 7; - - // The language filters applied to the output suggestions. If set, it should - // contain the language of the query. If not set, suggestions are returned - // without considering language restrictions. This is the BCP-47 language - // code, such as "en-US" or "sr-Latn". For more information, see [Tags for - // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - // number of language codes is 3. - repeated string language_codes = 3; - - // The device type context for completion suggestions. - // It is useful to apply different suggestions on different device types, e.g. - // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - // types. - // - // Supported formats: - // - // * `UNKNOWN_DEVICE_TYPE` - // - // * `DESKTOP` - // - // * `MOBILE` - // - // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - string device_type = 4; - - // Determines which dataset to use for fetching completion. "user-data" will - // use the imported dataset through - // [CompletionService.ImportCompletionData][google.cloud.retail.v2alpha.CompletionService.ImportCompletionData]. - // "cloud-retail" will use the dataset generated by cloud retail based on user - // events. If leave empty, it will use the "user-data". - // - // Current supported values: - // - // * user-data - // - // * cloud-retail - // This option requires additional allowlisting. Before using cloud-retail, - // contact Cloud Retail support team first. - string dataset = 6; - - // Completion max suggestions. If left unset or set to 0, then will fallback - // to the configured value - // [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions]. - // - // The maximum allowed max suggestions is 20. If it is set higher, it will be - // capped by 20. - int32 max_suggestions = 5; -} - -// Response of the auto-complete query. -message CompleteQueryResponse { - // Resource that represents completion results. - message CompletionResult { - // The suggestion for the query. - string suggestion = 1; - - // Custom attributes for the suggestion term. - // * For "user-data", the attributes are additional custom attributes - // ingested through BigQuery. - // * For "cloud-retail", the attributes are product attributes generated - // by Cloud Retail. - map attributes = 2; - } - - // Recent search of this user. - message RecentSearchResult { - // The recent search query. - string recent_search = 1; - } - - // Results of the matching suggestions. The result list is ordered and the - // first result is top suggestion. - repeated CompletionResult completion_results = 1; - - // A unique complete token. This should be included in the - // [UserEvent.completion_detail][google.cloud.retail.v2alpha.UserEvent.completion_detail] - // for search events resulting from this completion, which enables accurate - // attribution of complete model performance. - string attribution_token = 2; - - // Matched recent searches of this user. The maximum number of recent searches - // is 10. This field is a restricted feature. Contact Retail Search support - // team if you are interested in enabling it. - // - // This feature is only available when - // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2alpha.CompleteQueryRequest.visitor_id] - // field is set and [UserEvent][google.cloud.retail.v2alpha.UserEvent] is - // imported. The recent searches satisfy the follow rules: - // * They are ordered from latest to oldest. - // * They are matched with - // [CompleteQueryRequest.query][google.cloud.retail.v2alpha.CompleteQueryRequest.query] - // case insensitively. - // * They are transformed to lower cases. - // * They are UTF-8 safe. - // - // Recent searches are deduplicated. More recent searches will be reserved - // when duplication happens. - repeated RecentSearchResult recent_search_results = 3; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto deleted file mode 100644 index 4d85015e..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/search_service.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ControlProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Configures dynamic serving time metadata that is used to pre and post -// process search/recommendation model results. -message Control { - option (google.api.resource) = { - type: "retail.googleapis.com/Control" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" - }; - - // The behavior/type of the control - // - // A behavior/type must be specified on creation. Type cannot be changed once - // specified (e.g. A Rule control will always be a Rule control.). An - // INVALID_ARGUMENT will be returned if either condition is violated. - oneof control { - // A facet specification to perform faceted search. - SearchRequest.FacetSpec facet_spec = 3; - - // A rule control - a condition-action pair. - // Enacts a set action when the condition is triggered. - // For example: Boost "gShoe" when query full matches "Running Shoes". - Rule rule = 4; - } - - // Immutable. Fully qualified name - // projects/*/locations/global/catalogs/*/controls/* - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. The human readable control display name. Used in Retail UI. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is thrown. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Output only. List of serving configuration ids that that are associated - // with this control. Note the association is managed via the ServingConfig, - // this is an output only denormalizeed view. Assumed to be in the same - // catalog. - repeated string associated_serving_config_ids = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Immutable. The solution types that the serving config is used - // for. Currently we support setting only one type of solution at creation - // time. - // - // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. - // If no solution type is provided at creation time, will default to - // SOLUTION_TYPE_SEARCH. - repeated SolutionType solution_types = 6 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. Specifies the use case for the control. - // Affects what condition fields can be set. - // Only settable by search controls. - // Will default to SEARCH_SOLUTION_USE_CASE_SEARCH if not specified. - // Currently only allow one search_solution_use_case per control. - repeated SearchSolutionUseCase search_solution_use_case = 7 - [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto deleted file mode 100644 index 6372aca6..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/control.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ControlServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for modifying Control. -service ControlService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a Control. - // - // If the [Control][google.cloud.retail.v2alpha.Control] to create already - // exists, an ALREADY_EXISTS error is returned. - rpc CreateControl(CreateControlRequest) returns (Control) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" - body: "control" - }; - option (google.api.method_signature) = "parent,control,control_id"; - } - - // Deletes a Control. - // - // If the [Control][google.cloud.retail.v2alpha.Control] to delete does not - // exist, a NOT_FOUND error is returned. - rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a Control. - // - // [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different - // oneof field, if so an INVALID_ARGUMENT is returned. If the - // [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a - // NOT_FOUND error is returned. - rpc UpdateControl(UpdateControlRequest) returns (Control) { - option (google.api.http) = { - patch: "/v2alpha/{control.name=projects/*/locations/*/catalogs/*/controls/*}" - body: "control" - }; - option (google.api.method_signature) = "control,update_mask"; - } - - // Gets a Control. - rpc GetControl(GetControlRequest) returns (Control) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all Controls linked to this catalog. - rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Request for CreateControl method. -message CreateControlRequest { - // Required. Full resource name of parent catalog. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The Control to create. - Control control = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the Control, which will become the final - // component of the Control's resource name. - // - // This value should be 4-63 characters, and valid characters - // are /[a-z][0-9]-_/. - string control_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for UpdateControl method. -message UpdateControlRequest { - // Required. The Control to update. - Control control = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Control][google.cloud.retail.v2alpha.Control] to update. The following are - // NOT supported: - // - // * [Control.name][google.cloud.retail.v2alpha.Control.name] - // - // If not set or empty, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for DeleteControl method. -message DeleteControlRequest { - // Required. The resource name of the Control to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } - ]; -} - -// Request for GetControl method. -message GetControlRequest { - // Required. The resource name of the Control to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } - ]; -} - -// Request for ListControls method. -message ListControlsRequest { - // Required. The catalog resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Optional. Maximum number of results to return. If unspecified, defaults - // to 50. Max allowed value is 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListControls` call. - // Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2alpha.ListControlsRequest.filter] is unset. - // * List controls that are used in a single ServingConfig: - // 'serving_config = "boosted_home_page_cvr"' - string filter = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for ListControls method. -message ListControlsResponse { - // All the Controls for a given catalog. - repeated Control controls = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto deleted file mode 100644 index f29c7f9a..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ExportConfigProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Configuration of destination for Export related errors. -message ExportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage path for import errors. This must be an empty, - // existing Cloud Storage bucket. Export errors will be written to a file in - // this bucket, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Metadata related to the progress of the Export operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ExportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} - -// Response of the ExportProductsRequest. If the long running -// operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ExportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ExportErrorsConfig errors_config = 2; -} - -// Response of the ExportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ExportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ExportErrorsConfig errors_config = 2; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto deleted file mode 100644 index a1fcf240..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/product.proto"; -import "google/cloud/retail/v2alpha/user_event.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ImportConfigProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Google Cloud Storage location for input content. -// format. -message GcsSource { - // Required. Google Cloud Storage URIs to input files. URI can be up to - // 2000 characters long. URIs can match the full object path (for example, - // `gs://bucket/directory/object.json`) or a pattern matching one or more - // files, such as `gs://bucket/directory/*.json`. A request can - // contain at most 100 files, and each file can be up to 2 GB. See - // [Importing product - // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) - // for the expected file format and setup instructions. - repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON - // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. - // * `user_event_ga360`: Using - // https://support.google.com/analytics/answer/3437719. - // - // Supported values for control imports: - // - // * 'control' (default): One JSON - // [Control][google.cloud.retail.v2alpha.Control] per line. - // - // Supported values for catalog attribute imports: - // - // * 'catalog_attribute' (default): One CSV - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] per line. - string data_schema = 2; -} - -// BigQuery source import data from. -message BigQuerySource { - // BigQuery table partition info. Leave this empty if the BigQuery table - // is not partitioned. - oneof partition { - // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - google.type.Date partition_date = 6; - } - - // The project ID (can be project # or ID) that the BigQuery source is in with - // a length limit of 128 characters. If not specified, inherits the project - // ID from the parent request. - string project_id = 5; - - // Required. The BigQuery data set to copy the data from with a length limit - // of 1,024 characters. - string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The BigQuery table to copy the data from with a length limit of - // 1,024 characters. - string table_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Intermediate Cloud Storage directory used for the import with a length - // limit of 2,000 characters. Can be specified if one wants to have the - // BigQuery export to a specific Cloud Storage directory. - string gcs_staging_dir = 3; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON - // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. - // * `user_event_ga360`: - // The schema is available here: - // https://support.google.com/analytics/answer/3437719. - // * `user_event_ga4`: This feature is in private preview. Please contact the - // support team for importing Google Analytics 4 events. - // The schema is available here: - // https://support.google.com/analytics/answer/7029846. - // - // Supported values for auto-completion imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - string data_schema = 4; -} - -// The inline source for the input config for ImportProducts method. -message ProductInlineSource { - // Required. A list of products to update/create. Each product must have a - // valid [Product.id][google.cloud.retail.v2alpha.Product.id]. Recommended max - // of 100 items. - repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The inline source for the input config for ImportUserEvents method. -message UserEventInlineSource { - // Required. A list of user events to import. Recommended max of 10k items. - repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Configuration of destination for Import related errors. -message ImportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage prefix for import errors. This must be an empty, - // existing Cloud Storage directory. Import errors will be written to - // sharded files in this directory, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Request message for Import methods. -message ImportProductsRequest { - // Indicates how imported products are reconciled with the existing products - // created or imported before. - enum ReconciliationMode { - // Defaults to INCREMENTAL. - RECONCILIATION_MODE_UNSPECIFIED = 0; - - // Inserts new products or updates existing products. - INCREMENTAL = 1; - - // Calculates diff and replaces the entire product dataset. Existing - // products may be deleted if they are not present in the source location. - // - // Can only be set while using - // [BigQuerySource][google.cloud.retail.v2alpha.BigQuerySource]. And the - // BigQuery dataset must be created in the data location "us (multiple - // regions in United States)", otherwise a PERMISSION_DENIED error is - // thrown. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - FULL = 2; - } - - // Required. - // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - // - // If no updateMask is specified, requires products.create permission. - // If updateMask is specified, requires products.update permission. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Deprecated. This field has no effect. - string request_id = 6 [deprecated = true]; - - // Required. The desired input location of the data. - ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. - ImportErrorsConfig errors_config = 3; - - // Indicates which fields in the provided imported 'products' to update. If - // not set, will by default update all fields. - google.protobuf.FieldMask update_mask = 4; - - // The mode of reconciliation between existing products and the products to be - // imported. Defaults to - // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. - ReconciliationMode reconciliation_mode = 5; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - string notification_pubsub_topic = 7; -} - -// Request message for the ImportUserEvents request. -message ImportUserEventsRequest { - // Required. `projects/1234/locations/global/catalogs/default_catalog` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - UserEventInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. Cannot be set - // for inline user event imports. - ImportErrorsConfig errors_config = 3; -} - -// Request message for ImportCompletionData methods. -message ImportCompletionDataRequest { - // Required. The catalog which the suggestions dataset belongs to. - // - // Format: `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - CompletionDataInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 3; -} - -// The input config source for products. -message ProductInputConfig { - // Required. The source of the input. - oneof source { - // The Inline source for the input content for products. - ProductInlineSource product_inline_source = 1; - - // Google Cloud Storage location for the input content. - GcsSource gcs_source = 2; - - // BigQuery input source. - BigQuerySource big_query_source = 3; - } -} - -// The input config source for user events. -message UserEventInputConfig { - // The source of the input. - oneof source { - // Required. The Inline source for the input content for UserEvents. - UserEventInlineSource user_event_inline_source = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Google Cloud Storage location for the input content. - GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. BigQuery input source. - BigQuerySource big_query_source = 3 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// The input config source for completion data. -message CompletionDataInputConfig { - // The source of the input. - // - // Supported - // [BigQuerySource.data_schema][google.cloud.retail.v2alpha.BigQuerySource.data_schema] - // values for suggestions imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - oneof source { - // Required. BigQuery input source. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - BigQuerySource big_query_source = 1 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// Metadata related to the progress of the Import operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ImportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; - - // Deprecated. This field is never set. - string request_id = 5 [deprecated = true]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 6; -} - -// Response of the -// [ImportProductsRequest][google.cloud.retail.v2alpha.ImportProductsRequest]. -// If the long running operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ImportErrorsConfig errors_config = 2; -} - -// Response of the ImportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ImportErrorsConfig errors_config = 2; - - // Aggregated statistics of user event import status. - UserEventImportSummary import_summary = 3; -} - -// A summary of import result. The UserEventImportSummary summarizes -// the import status for user events. -message UserEventImportSummary { - // Count of user events imported with complete existing catalog information. - int64 joined_events_count = 1; - - // Count of user events imported, but with catalog information not found - // in the imported catalog. - int64 unjoined_events_count = 2; -} - -// Response of the -// [ImportCompletionDataRequest][google.cloud.retail.v2alpha.ImportCompletionDataRequest]. -// If the long running operation is done, this message is returned by the -// google.longrunning.Operations.response field if the operation is successful. -message ImportCompletionDataResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto deleted file mode 100644 index 5b89bceb..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2alpha/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "PredictionServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for making recommendation prediction. -service PredictionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Makes a recommendation prediction. - rpc Predict(PredictRequest) returns (PredictResponse) { - option (google.api.http) = { - post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" - body: "*" - }; - } -} - -// Request message for Predict method. -message PredictRequest { - // Required. Full resource name of the format: - // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} - // The ID of the Recommendations AI placement. Before you can request - // predictions from your model, you must create at least one placement for it. - // For more information, see [Managing - // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - // - // The full list of available placements can be seen at - // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Context about the user, what they are looking at and what action - // they took to trigger the predict request. Note that this user event detail - // won't be ingested to userEvent logs. Thus, a separate userEvent write - // request is required for event logging. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // Maximum number of results to return per page. Set this property - // to the number of prediction results needed. If zero, the service will - // choose a reasonable default. The maximum allowed value is 100. Values - // above 100 will be coerced to 100. - int32 page_size = 3; - - // The previous PredictResponse.next_page_token. - string page_token = 4; - - // Filter for restricting prediction results with a length limit of 5,000 - // characters. Accepts values for tags and the `filterOutOfStockItems` flag. - // - // * Tag expressions. Restricts predictions to products that match all of the - // specified tags. Boolean operators `OR` and `NOT` are supported if the - // expression is enclosed in parentheses, and must be separated from the - // tag values by a space. `-"tagA"` is also supported and is equivalent to - // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - // with a size limit of 1,000 characters. - // - // Note: "Recently viewed" models don't support tag filtering at the - // moment. - // - // * filterOutOfStockItems. Restricts predictions to products that do not - // have a - // stockState value of OUT_OF_STOCK. - // - // Examples: - // - // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - // * filterOutOfStockItems tag=(-"promotional") - // * filterOutOfStockItems - // - // If your filter blocks all prediction results, the API will return generic - // (unfiltered) popular products. If you only want results strictly matching - // the filters, set `strictFiltering` to True in `PredictRequest.params` to - // receive empty results instead. - // Note that the API will never return items with storageStatus of "EXPIRED" - // or "DELETED" regardless of filter choices. - string filter = 5; - - // Use validate only mode for this prediction query. If set to true, a - // dummy model will be used that returns arbitrary products. - // Note that the validate only mode should only be used for testing the API, - // or if the model is not ready. - bool validate_only = 6; - - // Additional domain specific parameters for the predictions. - // - // Allowed values: - // - // * `returnProduct`: Boolean. If set to true, the associated product - // object will be returned in the `results.metadata` field in the - // prediction response. - // * `returnScore`: Boolean. If set to true, the prediction 'score' - // corresponding to each returned product will be set in the - // `results.metadata` field in the prediction response. The given - // 'score' indicates the probability of an product being clicked/purchased - // given the user's context and history. - // * `strictFiltering`: Boolean. True by default. If set to false, the service - // will return generic (unfiltered) popular products instead of empty if - // your filter blocks all prediction results. - // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-price-reranking', 'low-price-reranking', - // 'medium-price-reranking', 'high-price-reranking'}. This gives - // request-level control and adjusts prediction results based on product - // price. - // * `diversityLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-diversity', 'low-diversity', - // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - // request-level control and adjusts prediction results based on product - // category. - map params = 7; - - // The labels applied to a resource must meet the following requirements: - // - // * Each resource can have multiple labels, up to a maximum of 64. - // * Each label must be a key-value pair. - // * Keys have a minimum length of 1 character and a maximum length of 63 - // characters, and cannot be empty. Values can be empty, and have a maximum - // length of 63 characters. - // * Keys and values can contain only lowercase letters, numeric characters, - // underscores, and dashes. All characters must use UTF-8 encoding, and - // international characters are allowed. - // * The key portion of a label must be unique. However, you can use the same - // key with multiple resources. - // * Keys must start with a lowercase letter or international character. - // - // See [Google Cloud - // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - // for more details. - map labels = 8; -} - -// Response message for predict method. -message PredictResponse { - // PredictionResult represents the recommendation prediction results. - message PredictionResult { - // ID of the recommended product - string id = 1; - - // Additional product metadata / annotations. - // - // Possible values: - // - // * `product`: JSON representation of the product. Will be set if - // `returnProduct` is set to true in `PredictRequest.params`. - // * `score`: Prediction score in double value. Will be set if - // `returnScore` is set to true in `PredictRequest.params`. - map metadata = 2; - } - - // A list of recommended products. The order represents the ranking (from the - // most relevant product to the least). - repeated PredictionResult results = 1; - - // A unique attribution token. This should be included in the - // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this - // recommendation, which enables accurate attribution of recommendation model - // performance. - string attribution_token = 2; - - // IDs of products in the request that were missing from the inventory. - repeated string missing_ids = 3; - - // True if the validateOnly property was set in the request. - bool validate_only = 4; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto deleted file mode 100644 index cbadc568..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto +++ /dev/null @@ -1,567 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/promotion.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; -option (google.api.resource_definition) = { - type: "retail.googleapis.com/Branch" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" -}; - -// Product captures all metadata information of items to be recommended or -// searched. -message Product { - option (google.api.resource) = { - type: "retail.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" - }; - - // The type of this product. - enum Type { - // Default value. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] - // if unset. - TYPE_UNSPECIFIED = 0; - - // The primary type. - // - // As the primary unit for predicting, indexing and search serving, a - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product] is grouped with multiple - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s. - PRIMARY = 1; - - // The variant type. - // - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s usually share some common - // attributes on the same - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s, but they have variant - // attributes like different colors, sizes and prices, etc. - VARIANT = 2; - - // The collection type. Collection products are bundled - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s or - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s that are sold together, - // such as a jewelry set with necklaces, earrings and rings, etc. - COLLECTION = 3; - } - - // Product availability. If this field is unspecified, the product is - // assumed to be in stock. - enum Availability { - // Default product availability. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK] - // if unset. - AVAILABILITY_UNSPECIFIED = 0; - - // Product in stock. - IN_STOCK = 1; - - // Product out of stock. - OUT_OF_STOCK = 2; - - // Product that is in pre-order state. - PREORDER = 3; - - // Product that is back-ordered (i.e. temporarily out of stock). - BACKORDER = 4; - } - - oneof expiration { - // The timestamp when this product becomes unavailable for - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // If it is set, the [Product][google.cloud.retail.v2alpha.Product] is not - // available for - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] - // after [expire_time][google.cloud.retail.v2alpha.Product.expire_time]. - // However, the product can still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] must be - // later than - // [available_time][google.cloud.retail.v2alpha.Product.available_time] and - // [publish_time][google.cloud.retail.v2alpha.Product.publish_time], - // otherwise an INVALID_ARGUMENT error is thrown. - // - // Corresponding properties: Google Merchant Center property - // [expiration_date](https://support.google.com/merchants/answer/6324499). - google.protobuf.Timestamp expire_time = 16; - - // Input only. The TTL (time to live) of the product. - // - // If it is set, it must be a non-negative value, and - // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is set as - // current timestamp plus [ttl][google.cloud.retail.v2alpha.Product.ttl]. - // The derived - // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is - // returned in the output and [ttl][google.cloud.retail.v2alpha.Product.ttl] - // is left blank when retrieving the - // [Product][google.cloud.retail.v2alpha.Product]. - // - // If it is set, the product is not available for - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] - // after current timestamp plus - // [ttl][google.cloud.retail.v2alpha.Product.ttl]. However, the product can - // still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - google.protobuf.Duration ttl = 17 - [(google.api.field_behavior) = INPUT_ONLY]; - } - - // Immutable. Full resource name of the product, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. [Product][google.cloud.retail.v2alpha.Product] identifier, which - // is the final component of [name][google.cloud.retail.v2alpha.Product.name]. - // For example, this field is "id_1", if - // [name][google.cloud.retail.v2alpha.Product.name] is - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [id](https://support.google.com/merchants/answer/6324405). Schema.org - // property [Product.sku](https://schema.org/sku). - string id = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The type of the product. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] - // if unset. - Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; - - // Variant group identifier. Must be an - // [id][google.cloud.retail.v2alpha.Product.id], with the same parent branch - // with this product. Otherwise, an error is thrown. - // - // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s, this field can only be - // empty or set to the same value as - // [id][google.cloud.retail.v2alpha.Product.id]. - // - // For VARIANT [Product][google.cloud.retail.v2alpha.Product]s, this field - // cannot be empty. A maximum of 2,000 products are allowed to share the same - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [item_group_id](https://support.google.com/merchants/answer/6324507). - // Schema.org property - // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). - string primary_product_id = 4; - - // The [id][google.cloud.retail.v2alpha.Product.id] of the collection members - // when [type][google.cloud.retail.v2alpha.Product.type] is - // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]. - // - // Non-existent product ids are allowed. - // The [type][google.cloud.retail.v2alpha.Product.type] of the members must be - // either [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] or - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] otherwise - // and INVALID_ARGUMENT error is thrown. Should not set it for other types. A - // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is - // return. - repeated string collection_member_ids = 5; - - // The Global Trade Item Number (GTIN) of the product. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Corresponding properties: Google Merchant Center property - // [gtin](https://support.google.com/merchants/answer/6324461). - // Schema.org property - // [Product.isbn](https://schema.org/isbn), - // [Product.gtin8](https://schema.org/gtin8), - // [Product.gtin12](https://schema.org/gtin12), - // [Product.gtin13](https://schema.org/gtin13), or - // [Product.gtin14](https://schema.org/gtin14). - // - // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. - string gtin = 6; - - // Product categories. This field is repeated for supporting one product - // belonging to several parallel categories. Strongly recommended using the - // full path for better search / recommendation quality. - // - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // For example, if a shoes product belongs to both - // ["Shoes & Accessories" -> "Shoes"] and - // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be - // represented as: - // - // "categories": [ - // "Shoes & Accessories > Shoes", - // "Sports & Fitness > Athletic Clothing > Shoes" - // ] - // - // Must be set for - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product] otherwise an - // INVALID_ARGUMENT error is returned. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2alpha.Product]. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [google_product_category][mc_google_product_category]. Schema.org property - // [Product.category] (https://schema.org/category). - // - // [mc_google_product_category]: - // https://support.google.com/merchants/answer/6324436 - repeated string categories = 7; - - // Required. Product title. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [title](https://support.google.com/merchants/answer/6324415). Schema.org - // property [Product.name](https://schema.org/name). - string title = 8 [(google.api.field_behavior) = REQUIRED]; - - // The brands of the product. - // - // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded - // string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [brand](https://support.google.com/merchants/answer/6324351). Schema.org - // property [Product.brand](https://schema.org/brand). - repeated string brands = 9; - - // Product description. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [description](https://support.google.com/merchants/answer/6324468). - // Schema.org property [Product.description](https://schema.org/description). - string description = 10; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // - // For product prediction, this field is ignored and the model automatically - // detects the text language. The - // [Product][google.cloud.retail.v2alpha.Product] can include text in - // different languages, but duplicating - // [Product][google.cloud.retail.v2alpha.Product]s to provide text in multiple - // languages can result in degraded model performance. - // - // For product search this field is in use. It defaults to "en-US" if unset. - string language_code = 11; - - // Highly encouraged. Extra product attributes to be included. For example, - // for products, this could include the store name, vendor, style, color, etc. - // These are very strong signals for recommendation model, thus we highly - // recommend providing the attributes here. - // - // Features that can take on one of a limited number of possible values. Two - // types of features can be set are: - // - // Textual features. some examples would be the brand/maker of a product, or - // country of a customer. Numerical features. Some examples would be the - // height/weight of a product, or age of a customer. - // - // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, - // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} - // }`. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * Max entries count: 200. - // * The key must be a UTF-8 encoded string with a length limit of 128 - // characters. - // * For indexable attribute, the key must match the pattern: - // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or - // `KEY_1_LIKE_THIS`. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a non-empty UTF-8 encoded string with a - // length limit of 256 characters. - // * For number attributes, at most 400 values are allowed. - map attributes = 12; - - // Custom tags associated with the product. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2alpha.Product]. This value must be a UTF-8 - // encoded string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This tag can be used for filtering recommendation results by passing the - // tag as part of the - // [PredictRequest.filter][google.cloud.retail.v2alpha.PredictRequest.filter]. - // - // Corresponding properties: Google Merchant Center property - // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). - repeated string tags = 13; - - // Product price and cost information. - // - // Corresponding properties: Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 14; - - // The rating of this product. - Rating rating = 15; - - // The timestamp when this [Product][google.cloud.retail.v2alpha.Product] - // becomes available for - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - google.protobuf.Timestamp available_time = 18; - - // The online availability of the - // [Product][google.cloud.retail.v2alpha.Product]. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK]. - // - // Corresponding properties: Google Merchant Center property - // [availability](https://support.google.com/merchants/answer/6324448). - // Schema.org property [Offer.availability](https://schema.org/availability). - Availability availability = 19; - - // The available quantity of the item. - google.protobuf.Int32Value available_quantity = 20; - - // Fulfillment information, such as the store IDs for in-store pickup or - // region IDs for different shipping methods. - // - // All the elements must have distinct - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated FulfillmentInfo fulfillment_info = 21; - - // Canonical URL directly linking to the product detail page. - // - // It is strongly recommended to provide a valid uri for the product, - // otherwise the service performance could be significantly degraded. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [link](https://support.google.com/merchants/answer/6324416). Schema.org - // property [Offer.url](https://schema.org/url). - string uri = 22; - - // Product images for the product. We highly recommend putting the main - // image first. - // - // A maximum of 300 images are allowed. - // - // Corresponding properties: Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - repeated Image images = 23; - - // The target group associated with a given audience (e.g. male, veterans, - // car owners, musicians, etc.) of the product. - Audience audience = 24; - - // The color of the product. - // - // Corresponding properties: Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - ColorInfo color_info = 25; - - // The size of the product. To represent different size systems or size types, - // consider using this format: [[[size_system:]size_type:]size_value]. - // - // For example, in "US:MENS:M", "US" represents size system; "MENS" represents - // size type; "M" represents size value. In "GIRLS:27", size system is empty; - // "GIRLS" represents size type; "27" represents size value. In "32 inches", - // both size system and size type are empty, while size value is "32 inches". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [size](https://support.google.com/merchants/answer/6324492), - // [size_type](https://support.google.com/merchants/answer/6324497), and - // [size_system](https://support.google.com/merchants/answer/6324502). - // Schema.org property [Product.size](https://schema.org/size). - repeated string sizes = 26; - - // The material of the product. For example, "leather", "wooden". - // - // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 200 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [material](https://support.google.com/merchants/answer/6324410). Schema.org - // property [Product.material](https://schema.org/material). - repeated string materials = 27; - - // The pattern or graphic print of the product. For example, "striped", "polka - // dot", "paisley". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org - // property [Product.pattern](https://schema.org/pattern). - repeated string patterns = 28; - - // The condition of the product. Strongly encouraged to use the standard - // values: "new", "refurbished", "used". - // - // A maximum of 1 value is allowed per - // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [condition](https://support.google.com/merchants/answer/6324469). - // Schema.org property - // [Offer.itemCondition](https://schema.org/itemCondition). - repeated string conditions = 29; - - // The promotions applied to the product. A maximum of 10 values are allowed - // per [Product][google.cloud.retail.v2alpha.Product]. Only - // [Promotion.promotion_id][google.cloud.retail.v2alpha.Promotion.promotion_id] - // will be used, other fields will be ignored if set. - repeated Promotion promotions = 34; - - // The timestamp when the product is published by the retailer for the first - // time, which indicates the freshness of the products. Note that this field - // is different from - // [available_time][google.cloud.retail.v2alpha.Product.available_time], given - // it purely describes product freshness regardless of when it is available on - // search and recommendation. - google.protobuf.Timestamp publish_time = 33; - - // Indicates which fields in the - // [Product][google.cloud.retail.v2alpha.Product]s are returned in - // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse]. - // - // Supported fields for all [type][google.cloud.retail.v2alpha.Product.type]s: - // - // * [audience][google.cloud.retail.v2alpha.Product.audience] - // * [availability][google.cloud.retail.v2alpha.Product.availability] - // * [brands][google.cloud.retail.v2alpha.Product.brands] - // * [color_info][google.cloud.retail.v2alpha.Product.color_info] - // * [conditions][google.cloud.retail.v2alpha.Product.conditions] - // * [gtin][google.cloud.retail.v2alpha.Product.gtin] - // * [materials][google.cloud.retail.v2alpha.Product.materials] - // * [name][google.cloud.retail.v2alpha.Product.name] - // * [patterns][google.cloud.retail.v2alpha.Product.patterns] - // * [price_info][google.cloud.retail.v2alpha.Product.price_info] - // * [rating][google.cloud.retail.v2alpha.Product.rating] - // * [sizes][google.cloud.retail.v2alpha.Product.sizes] - // * [title][google.cloud.retail.v2alpha.Product.title] - // * [uri][google.cloud.retail.v2alpha.Product.uri] - // - // Supported fields only for - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]: - // - // * [categories][google.cloud.retail.v2alpha.Product.categories] - // * [description][google.cloud.retail.v2alpha.Product.description] - // * [images][google.cloud.retail.v2alpha.Product.images] - // - // Supported fields only for - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]: - // - // * Only the first image in - // [images][google.cloud.retail.v2alpha.Product.images] - // - // To mark [attributes][google.cloud.retail.v2alpha.Product.attributes] as - // retrievable, include paths of the form "attributes.key" where "key" is the - // key of a custom attribute, as specified in - // [attributes][google.cloud.retail.v2alpha.Product.attributes]. - // - // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], the - // following fields are always returned in - // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] by default: - // - // * [name][google.cloud.retail.v2alpha.Product.name] - // - // For [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT], the - // following fields are always returned in by default: - // - // * [name][google.cloud.retail.v2alpha.Product.name] - // * [color_info][google.cloud.retail.v2alpha.Product.color_info] - // - // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Note: Returning more fields in - // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] may increase - // response payload size and serving latency. - google.protobuf.FieldMask retrievable_fields = 30; - - // Output only. Product variants grouped together on primary product which - // share similar product attributes. It's automatically grouped by - // [primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] - // for all the product variants. Only populated for - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. - // Do not set this field in API requests. - repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto deleted file mode 100644 index 7bced3fb..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto +++ /dev/null @@ -1,882 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/import_config.proto"; -import "google/cloud/retail/v2alpha/product.proto"; -import "google/cloud/retail/v2alpha/purge_config.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for ingesting [Product][google.cloud.retail.v2alpha.Product] -// information of the customer's website. -service ProductService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a [Product][google.cloud.retail.v2alpha.Product]. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Gets a [Product][google.cloud.retail.v2alpha.Product]. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Product][google.cloud.retail.v2alpha.Product]s. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a [Product][google.cloud.retail.v2alpha.Product]. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v2alpha/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Deletes a [Product][google.cloud.retail.v2alpha.Product]. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Permanently deletes all selected - // [Product][google.cloud.retail.v2alpha.Product]s under a branch. - // - // This process is asynchronous. If the request is valid, the removal will be - // enqueued and processed offline. Depending on the number of - // [Product][google.cloud.retail.v2alpha.Product]s, this operation could take - // hours to complete. Before the operation completes, some - // [Product][google.cloud.retail.v2alpha.Product]s may still be returned by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, - // this operation could take hours to complete. To get a sample of - // [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set - // [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] - // to false. - rpc PurgeProducts(PurgeProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:purge" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.PurgeProductsResponse" - metadata_type: "google.cloud.retail.v2alpha.PurgeProductsMetadata" - }; - } - - // Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. - // - // Request processing may be synchronous. No partial updating is supported. - // Non-existing items are created. - // - // Note that it is possible for a subset of the - // [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated. - rpc ImportProducts(ImportProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.ImportProductsResponse" - metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" - }; - } - - // Updates inventory information for a - // [Product][google.cloud.retail.v2alpha.Product] while respecting the last - // update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2alpha.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, updates are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // When inventory is updated with - // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], - // the specified inventory field value(s) will overwrite any existing value(s) - // while ignoring the last update time for this field. Furthermore, the last - // update time for the specified inventory fields will be overwritten to the - // time of the - // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // or - // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] - // request. - // - // If no inventory fields are set in - // [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], - // then any pre-existing inventory information for this product will be used. - // - // If no inventory fields are set in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], - // then any existing inventory information will be preserved. - // - // Pre-existing inventory information can only be updated with - // [SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], - // [AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], - // and - // [RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" - body: "*" - }; - option (google.api.method_signature) = "inventory,set_mask"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.SetInventoryResponse" - metadata_type: "google.cloud.retail.v2alpha.SetInventoryMetadata" - }; - } - - // Incrementally adds place IDs to - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2alpha.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the added place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata" - }; - } - - // Incrementally removes place IDs from a - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2alpha.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the removed place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata" - }; - } - - // Updates local inventory information for a - // [Product][google.cloud.retail.v2alpha.Product] at a list of places, while - // respecting the last update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2alpha.Product] to exist before updating - // inventory information. If the request is valid, the update will be enqueued - // and processed downstream. As a consequence, when a response is returned, - // updates are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // Local inventory information can only be modified using this method. - // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddLocalInventories(AddLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.AddLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2alpha.AddLocalInventoriesMetadata" - }; - } - - // Remove local inventory information for a - // [Product][google.cloud.retail.v2alpha.Product] at a list of places at a - // removal timestamp. - // - // This process is asynchronous. If the request is valid, the removal will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, removals are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // Local inventory information can only be removed using this method. - // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata" - }; - } -} - -// Request message for [CreateProduct][] method. -message CreateProductRequest { - // Required. The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Required. The [Product][google.cloud.retail.v2alpha.Product] to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the - // [Product][google.cloud.retail.v2alpha.Product], which will become the final - // component of the [Product.name][google.cloud.retail.v2alpha.Product.name]. - // - // If the caller does not have permission to create the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // This field must be unique among all - // [Product][google.cloud.retail.v2alpha.Product]s with the same - // [parent][google.cloud.retail.v2alpha.CreateProductRequest.parent]. - // Otherwise, an ALREADY_EXISTS error is returned. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string product_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [GetProduct][] method. -message GetProductRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // If the requested [Product][google.cloud.retail.v2alpha.Product] does not - // exist, a NOT_FOUND error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for [UpdateProduct][] method. -message UpdateProductRequest { - // Required. The product to update/create. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2alpha.Product] to update does not - // exist and - // [allow_missing][google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing] - // is not set, a NOT_FOUND error is returned. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Product][google.cloud.retail.v2alpha.Product] to update. The immutable and - // output only fields are NOT supported. If not set, all supported fields (the - // fields that are neither immutable nor output only) are updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, a new [Product][google.cloud.retail.v2alpha.Product] will be - // created. In this situation, `update_mask` is ignored. - bool allow_missing = 3; -} - -// Request message for [DeleteProduct][] method. -message DeleteProductRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to delete the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2alpha.Product] to delete does not - // exist, a NOT_FOUND error is returned. - // - // The [Product][google.cloud.retail.v2alpha.Product] to delete can neither be - // a - // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2alpha.Product] member nor a - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product] with more than one - // [variants][google.cloud.retail.v2alpha.Product.Type.VARIANT]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // All inventory information for the named - // [Product][google.cloud.retail.v2alpha.Product] will be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for -// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] -// method. -message ListProductsRequest { - // Required. The parent branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use - // `default_branch` as the branch ID, to list products under the default - // branch. - // - // If the caller does not have permission to list - // [Product][google.cloud.retail.v2alpha.Product]s under this branch, - // regardless of whether or not this branch exists, a PERMISSION_DENIED error - // is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to - // return. If unspecified, defaults to 100. The maximum allowed value is 1000. - // Values above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT error is returned. - int32 page_size = 2; - - // A page token - // [ListProductsResponse.next_page_token][google.cloud.retail.v2alpha.ListProductsResponse.next_page_token], - // received from a previous - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; - - // A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2alpha.ListProductsRequest.filter] is unset. - // * List - // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s sharing the same - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]. For example: - // `primary_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2alpha.Product]s bundled in a - // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2alpha.Product]. - // For example: - // `collection_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2alpha.Product]s with a partibular - // type. For example: - // `type = "PRIMARY"` - // `type = "VARIANT"` - // `type = "COLLECTION"` - // - // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - // - // If the specified - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product] or - // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2alpha.Product] does not exist, a NOT_FOUND - // error is returned. - string filter = 4; - - // The fields of [Product][google.cloud.retail.v2alpha.Product] to return in - // the responses. If not set or empty, the following fields are returned: - // - // * [Product.name][google.cloud.retail.v2alpha.Product.name] - // * [Product.id][google.cloud.retail.v2alpha.Product.id] - // * [Product.title][google.cloud.retail.v2alpha.Product.title] - // * [Product.uri][google.cloud.retail.v2alpha.Product.uri] - // * [Product.images][google.cloud.retail.v2alpha.Product.images] - // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] - // * [Product.brands][google.cloud.retail.v2alpha.Product.brands] - // - // If "*" is provided, all fields are returned. - // [Product.name][google.cloud.retail.v2alpha.Product.name] is always returned - // no matter what mask is set. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask read_mask = 5; - - // If true and - // [page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] is - // empty, - // [ListProductsResponse.total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] - // is set to the total count of matched items irrespective of pagination. - // - // Notice that setting this field to true affects the performance. - bool require_total_size = 6; -} - -// Response message for -// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] -// method. -message ListProductsResponse { - // The [Product][google.cloud.retail.v2alpha.Product]s. - repeated Product products = 1; - - // A token that can be sent as - // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; - - // The total count of matched [Product][google.cloud.retail.v2alpha.Product]s - // irrespective of pagination. The total number of - // [Product][google.cloud.retail.v2alpha.Product]s returned by pagination may - // be less than the - // [total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] - // that matches. - // - // This field is ignored if - // [ListProductsRequest.require_total_size][google.cloud.retail.v2alpha.ListProductsRequest.require_total_size] - // is not set or - // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] - // is not empty. - int32 total_size = 3; -} - -// Request message for [SetInventory][] method. -message SetInventoryRequest { - // Required. The inventory information to update. The allowable fields to - // update are: - // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] - // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] - // The updated inventory fields must be specified in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask]. - // - // If [SetInventoryRequest.inventory.name][] is empty or invalid, an - // INVALID_ARGUMENT error is returned. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2alpha.Product] named in - // [Product.name][google.cloud.retail.v2alpha.Product.name], regardless of - // whether or not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2alpha.Product] to update does not - // have existing inventory information, the provided inventory information - // will be inserted. - // - // If the [Product][google.cloud.retail.v2alpha.Product] to update has - // existing inventory information, the provided inventory information will be - // merged while respecting the last update time for each inventory field, - // using the provided or default value for - // [SetInventoryRequest.set_time][google.cloud.retail.v2alpha.SetInventoryRequest.set_time]. - // - // The caller can replace place IDs for a subset of fulfillment types in the - // following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types and corresponding place IDs - // to update in [SetInventoryRequest.inventory.fulfillment_info][] - // - // The caller can clear all place IDs from a subset of fulfillment types in - // the following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types to clear in - // [SetInventoryRequest.inventory.fulfillment_info][] - // * Checks that only the desired fulfillment info types have empty - // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] - // - // The last update time is recorded for the following inventory fields: - // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] - // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] - // - // If a full overwrite of inventory information while ignoring timestamps is - // needed, [UpdateProduct][] should be invoked instead. - Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided - // [Product][google.cloud.retail.v2alpha.Product] to update. - // - // At least one field must be provided. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask set_mask = 2; - - // The time when the request is issued, used to prevent - // out-of-order updates on inventory fields with the last update time - // recorded. If not provided, the internal system time will be used. - google.protobuf.Timestamp set_time = 3; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] with - // name [Product.name][google.cloud.retail.v2alpha.Product.name] is not found, - // the inventory update will still be processed and retained for at most 1 day - // until the [Product][google.cloud.retail.v2alpha.Product] is created. If set - // to false, a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 4; -} - -// Metadata related to the progress of the SetInventory operation. -// Currently empty because there is no meaningful metadata populated from the -// [SetInventory][] method. -message SetInventoryMetadata {} - -// Response of the SetInventoryRequest. Currently empty because -// there is no meaningful response populated from the [SetInventory][] -// method. -message SetInventoryResponse {} - -// Request message for [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type], such - // as the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery" to be added for this - // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type]. - // Duplicate IDs will be automatically ignored. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // If the total number of place IDs exceeds 2000 for this - // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type] after - // adding, then the update will be rejected. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, the fulfillment information will still be processed and retained - // for at most 1 day and processed once the - // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the AddFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesMetadata {} - -// Response of the AddFulfillmentPlacesRequest. Currently empty because -// there is no meaningful response populated from the [AddFulfillmentPlaces][] -// method. -message AddFulfillmentPlacesResponse {} - -// Request message for [AddLocalInventories][] method. -message AddLocalInventoriesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of inventory information at difference places. Each place - // is identified by its place ID. At most 3000 inventories are allowed per - // request. - repeated LocalInventory local_inventories = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided list of - // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory] to update. The - // field is updated to the provided value. - // - // If a field is set while the place does not have a previous local inventory, - // the local inventory at that store is created. - // - // If a field is set while the value of that field is not provided, the - // original field value, if it exists, is deleted. - // - // If the mask is not set or set with empty paths, all inventory fields will - // be updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask add_mask = 4; - - // The time when the inventory updates are issued. Used to prevent - // out-of-order updates on local inventory fields. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, the local inventory will still be processed and retained for at - // most 1 day and processed once the - // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 6; -} - -// Metadata related to the progress of the AddLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddLocalInventories][] method. -message AddLocalInventoriesMetadata {} - -// Response of the [AddLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [AddLocalInventories][] -// method. -message AddLocalInventoriesResponse {} - -// Request message for [RemoveLocalInventories][] method. -message RemoveLocalInventoriesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of place IDs to have their inventory deleted. - // At most 3000 place IDs are allowed per request. - repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; - - // The time when the inventory deletions are issued. Used to prevent - // out-of-order updates and deletions on local inventory fields. If not - // provided, the internal system time will be used. - google.protobuf.Timestamp remove_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, the local inventory removal request will still be processed and - // retained for at most 1 day and processed once the - // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 3; -} - -// Metadata related to the progress of the RemoveLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveLocalInventories][] method. -message RemoveLocalInventoriesMetadata {} - -// Response of the [RemoveLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [RemoveLocalInventories][] -// method. -message RemoveLocalInventoriesResponse {} - -// Request message for [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type], - // such as the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery", to be removed for this - // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type]. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp remove_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, the fulfillment information will still be processed and retained - // for at most 1 day and processed once the - // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the RemoveFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesMetadata {} - -// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there -// is no meaningful response populated from the [RemoveFulfillmentPlaces][] -// method. -message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto deleted file mode 100644 index 879449a4..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "PromotionProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Promotion information. -message Promotion { - // ID of the promotion. For example, "free gift". - // - // The value must be a UTF-8 encoded string with a length limit of 128 - // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, - // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Google Merchant Center property - // [promotion](https://support.google.com/merchants/answer/7050148). - string promotion_id = 1; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto deleted file mode 100644 index 6b929f26..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "PurgeConfigProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Metadata related to the progress of the Purge operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeMetadata {} - -// Metadata related to the progress of the PurgeProducts operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeProductsMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were deleted successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; -} - -// Request message for PurgeProducts method. -message PurgeProductsRequest { - // Required. The resource name of the branch under which the products are - // created. The format is - // `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Required. The filter string to specify the products to be deleted with a - // length limit of 5,000 characters. - // - // Empty string filter is not allowed. "*" implies delete all items in a - // branch. - // - // The eligible fields for filtering are: - // - // * `availability`: Double quoted - // [Product.availability][google.cloud.retail.v2alpha.Product.availability] - // string. - // * `create_time` : in ISO 8601 "zulu" format. - // - // Supported syntax: - // - // * Comparators (">", "<", ">=", "<=", "="). - // Examples: - // * create_time <= "2015-02-13T17:05:46Z" - // * availability = "IN_STOCK" - // - // * Conjunctions ("AND") - // Examples: - // * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" - // - // * Disjunctions ("OR") - // Examples: - // * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" - // - // * Can support nested queries. - // Examples: - // * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") - // OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") - // - // * Filter Limits: - // * Filter should not contain more than 6 conditions. - // * Max nesting depth should not exceed 2 levels. - // - // Examples queries: - // * Delete back order products created before a timestamp. - // create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually perform the purge. - // If `force` is set to false, the method will return the expected purge count - // without deleting any products. - bool force = 3; -} - -// Response of the PurgeProductsRequest. If the long running operation is -// successfully done, then this message is returned by the -// google.longrunning.Operations.response field. -message PurgeProductsResponse { - // The total count of products purged as a result of the operation. - int64 purge_count = 1; - - // A sample of the product names that will be deleted. - // Only populated if `force` is set to false. A max of 100 names will be - // returned and the names are chosen at random. - repeated string purge_sample = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for PurgeUserEvents method. -message PurgeUserEventsRequest { - // Required. The resource name of the catalog under which the events are - // created. The format is - // `projects/${projectId}/locations/global/catalogs/${catalogId}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The filter string to specify the events to be deleted with a - // length limit of 5,000 characters. Empty string filter is not allowed. The - // eligible fields for filtering are: - // - // * `eventType`: Double quoted - // [UserEvent.event_type][google.cloud.retail.v2alpha.UserEvent.event_type] - // string. - // * `eventTime`: in ISO 8601 "zulu" format. - // * `visitorId`: Double quoted string. Specifying this will delete all - // events associated with a visitor. - // * `userId`: Double quoted string. Specifying this will delete all events - // associated with a user. - // - // Examples: - // - // * Deleting all events in a time range: - // `eventTime > "2012-04-23T18:25:43.511Z" - // eventTime < "2012-04-23T18:30:43.511Z"` - // * Deleting specific eventType in time range: - // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - // * Deleting all events for a specific visitor: - // `visitorId = "visitor1024"` - // - // The filtering fields are assumed to have an implicit AND. - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually perform the purge. - // If `force` is set to false, the method will return the expected purge count - // without deleting any user events. - bool force = 3; -} - -// Response of the PurgeUserEventsRequest. If the long running operation is -// successfully done, then this message is returned by the -// google.longrunning.Operations.response field. -message PurgeUserEventsResponse { - // The total count of events purged as a result of the operation. - int64 purged_events_count = 1; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto deleted file mode 100644 index f9612734..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto +++ /dev/null @@ -1,832 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/product.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "SearchServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for search. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service SearchService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Performs a search. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc Search(SearchRequest) returns (SearchResponse) { - option (google.api.http) = { - post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" - body: "*" - }; - } -} - -// Request message for -// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] -// method. -message SearchRequest { - // A facet specification to perform faceted search. - message FacetSpec { - // Specifies how a facet is computed. - message FacetKey { - // Required. Supported textual and numerical facet keys in - // [Product][google.cloud.retail.v2alpha.Product] object, over which the - // facet values are computed. Facet key is case-sensitive. - // - // Allowed facet keys when - // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] - // is not specified: - // - // * textual_field = - // * "brands" - // * "categories" - // * "genders" - // * "ageGroups" - // * "availability" - // * "colorFamilies" - // * "colors" - // * "sizes" - // * "materials" - // * "patterns" - // * "conditions" - // * "attributes.key" - // * "pickupInStore" - // * "shipToStore" - // * "sameDayDelivery" - // * "nextDayDelivery" - // * "customFulfillment1" - // * "customFulfillment2" - // * "customFulfillment3" - // * "customFulfillment4" - // * "customFulfillment5" - // * "inventory(place_id,attributes.key)" - // - // * numerical_field = - // * "price" - // * "discount" - // * "rating" - // * "ratingCount" - // * "attributes.key" - // * "inventory(place_id,price)" - // * "inventory(place_id,original_price)" - // * "inventory(place_id,attributes.key)" - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Set only if values should be bucketized into intervals. Must be set - // for facets with numerical values. Must not be set for facet with text - // values. Maximum number of intervals is 30. - repeated Interval intervals = 2; - - // Only get facet for the given restricted values. For example, when using - // "pickupInStore" as key and set restricted values to - // ["store123", "store456"], only facets for "store123" and "store456" are - // returned. Only supported on textual fields and fulfillments. - // Maximum is 20. - // - // Must be set for the fulfillment facet keys: - // - // * pickupInStore - // - // * shipToStore - // - // * sameDayDelivery - // - // * nextDayDelivery - // - // * customFulfillment1 - // - // * customFulfillment2 - // - // * customFulfillment3 - // - // * customFulfillment4 - // - // * customFulfillment5 - repeated string restricted_values = 3; - - // Only get facet values that start with the given string prefix. For - // example, suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the - // "categories" facet will give only "Women > Shoe" and "Women > Dress". - // Only supported on textual fields. Maximum is 10. - repeated string prefixes = 8; - - // Only get facet values that contains the given strings. For example, - // suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the - // "categories" facet will give only "Women > Shoe" and "Men > Shoe". - // Only supported on textual fields. Maximum is 10. - repeated string contains = 9; - - // The order in which [Facet.values][] are returned. - // - // Allowed values are: - // - // * "count desc", which means order by [Facet.FacetValue.count][] - // descending. - // - // * "value desc", which means order by [Facet.FacetValue.value][] - // descending. - // Only applies to textual facets. - // - // If not set, textual values are sorted in [natural - // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical - // intervals are sorted in the order given by - // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.intervals]; - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // are sorted in the order given by - // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.restricted_values]. - string order_by = 4; - - // The query that is used to compute facet for the given facet key. - // When provided, it will override the default behavior of facet - // computation. The query syntax is the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for detail syntax and limitations. Notice that there is no limitation - // on - // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] - // when query is specified. - // - // In the response, [FacetValue.value][] will be always "1" and - // [FacetValue.count][] will be the number of results that matches the - // query. - // - // For example, you can set a customized facet for "shipToStore", - // where - // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] - // is "customizedShipToStore", and - // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] - // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". - // Then the facet will count the products that are both in stock and ship - // to store "123". - string query = 5; - } - - // Required. The facet key specification. - FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum of facet values that should be returned for this facet. If - // unspecified, defaults to 20. The maximum allowed value is 300. Values - // above 300 will be coerced to 300. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 limit = 2; - - // List of keys to exclude when faceting. - // - // By default, - // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] - // is not excluded from the filter unless it is listed in this field. - // - // For example, suppose there are 100 products with color facet "Red" and - // 200 products with color facet "Blue". A query containing the filter - // "colorFamilies:ANY("Red")" and have "colorFamilies" as - // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] - // will by default return the "Red" with count 100. - // - // If this field contains "colorFamilies", then the query returns both the - // "Red" with count 100 and "Blue" with count 200, because the - // "colorFamilies" key is now excluded from the filter. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated string excluded_filter_keys = 3; - - // Enables dynamic position for this facet. If set to true, the position of - // this facet among all facets in the response is determined by Google - // Retail Search. It will be ordered together with dynamic facets if dynamic - // facets is enabled. If set to false, the position of this facet in the - // response will be the same as in the request, and it will be ranked before - // the facets with dynamic position enable and all dynamic facets. - // - // For example, you may always want to have rating facet returned in - // the response, but it's not necessarily to always display the rating facet - // at the top. In that case, you can set enable_dynamic_position to true so - // that the position of rating facet in response will be determined by - // Google Retail Search. - // - // Another example, assuming you have the following facets in the request: - // - // * "rating", enable_dynamic_position = true - // - // * "price", enable_dynamic_position = false - // - // * "brands", enable_dynamic_position = false - // - // And also you have a dynamic facets enable, which will generate a facet - // 'gender'. Then the final order of the facets in the response can be - // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", - // "rating") depends on how Google Retail Search orders "gender" and - // "rating" facets. However, notice that "price" and "brands" will always be - // ranked at 1st and 2nd position since their enable_dynamic_position are - // false. - bool enable_dynamic_position = 4; - } - - // The specifications of dynamically generated facets. - message DynamicFacetSpec { - // Enum to control DynamicFacet mode - enum Mode { - // Default value. - MODE_UNSPECIFIED = 0; - - // Disable Dynamic Facet. - DISABLED = 1; - - // Automatic mode built by Google Retail Search. - ENABLED = 2; - } - - // Mode of the DynamicFacet feature. - // Defaults to - // [Mode.DISABLED][google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode.DISABLED] - // if it's unset. - Mode mode = 1; - } - - // Boost specification to boost certain items. - message BoostSpec { - // Boost applies to products which match a condition. - message ConditionBoostSpec { - // An expression which specifies a boost condition. The syntax and - // supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue": - // * (id: ANY("product_1", "product_2")) AND (colorFamilies: - // ANY("Red","Blue")) - string condition = 1; - - // Strength of the condition boost, which should be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 2; - } - - // Condition boost specifications. If a product matches multiple conditions - // in the specifictions, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 10. - repeated ConditionBoostSpec condition_boost_specs = 1; - - // Whether to skip boostspec validation. If this field is set to true, - // invalid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] - // will be ignored and valid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] - // will still be applied. - optional bool skip_boost_spec_validation = 2; - } - - // Specification to determine under which conditions query expansion should - // occur. - message QueryExpansionSpec { - // Enum describing under which condition query expansion should occur. - enum Condition { - // Unspecified query expansion condition. This defaults to - // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - CONDITION_UNSPECIFIED = 0; - - // Disabled query expansion. Only the exact search query is used, even if - // [SearchResponse.total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] - // is zero. - DISABLED = 1; - - // Automatic query expansion built by Google Retail Search. - AUTO = 3; - } - - // The condition under which query expansion should occur. Default to - // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - Condition condition = 1; - - // Whether to pin unexpanded results. If this field is set to true, - // unexpanded products are always at the top of the search results, followed - // by the expanded results. - bool pin_unexpanded_results = 2; - } - - // The specification for personalization. - message PersonalizationSpec { - // The personalization mode of each search request. - enum Mode { - // Default value. Defaults to - // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Let CRS decide whether to use personalization. - AUTO = 1; - - // Disable personalization. - DISABLED = 2; - } - - // Defaults to - // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. - Mode mode = 1; - } - - // The relevance threshold of the search results. The higher relevance - // threshold is, the higher relevant results are shown and the less number of - // results are returned. - enum RelevanceThreshold { - // Default value. Defaults to - // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH]. - RELEVANCE_THRESHOLD_UNSPECIFIED = 0; - - // High relevance threshold. - HIGH = 1; - - // Medium relevance threshold. - MEDIUM = 2; - - // Low relevance threshold. - LOW = 3; - - // Lowest relevance threshold. - LOWEST = 4; - } - - // The search mode of each search request. - enum SearchMode { - // Default value. In this case both product search and faceted search will - // be performed. Both [SearchResponse.SearchResult] and - // [SearchResponse.Facet] will be returned. - SEARCH_MODE_UNSPECIFIED = 0; - - // Only product search will be performed. The faceted search will be - // disabled. - // - // Only [SearchResponse.SearchResult] will be returned. - // [SearchResponse.Facet] will not be returned, even if - // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] - // or - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] - // is set. - PRODUCT_SEARCH_ONLY = 1; - - // Only faceted search will be performed. The product search will be - // disabled. - // - // When in this mode, one or both of [SearchRequest.facet_spec][] and - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] - // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only - // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] - // will not be returned. - FACETED_SEARCH_ONLY = 2; - } - - // Required. The resource name of the search engine placement, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` - // This field is used to identify the serving configuration name and the set - // of models that will be used to make the search. - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. - // - // Use "default_branch" as the branch ID or leave this field empty, to search - // products under the default branch. - string branch = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Raw search query. - string query = 3; - - // Required. A unique identifier for tracking visitors. For example, this - // could be implemented with an HTTP cookie, which should be able to uniquely - // identify a visitor on a single device. This unique identifier should not - // change if the visitor logs in or out of the website. - // - // This should be the same identifier as - // [UserEvent.visitor_id][google.cloud.retail.v2alpha.UserEvent.visitor_id]. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; - - // User information. - UserInfo user_info = 5; - - // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to - // return. If unspecified, defaults to a reasonable value. The maximum allowed - // value is 120. Values above 120 will be coerced to 120. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 7; - - // A page token - // [SearchResponse.next_page_token][google.cloud.retail.v2alpha.SearchResponse.next_page_token], - // received from a previous - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 8; - - // A 0-indexed integer that specifies the current offset (that is, starting - // result location, amongst the - // [Product][google.cloud.retail.v2alpha.Product]s deemed by the API as - // relevant) in search results. This field is only considered if - // [page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] is - // unset. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 offset = 9; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. Filter - // expression is case-sensitive. See more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string filter = 10; - - // The default filter that is applied when a user performs a search without - // checking any filters on the search page. - // - // The filter applied to every search request when quality improvement such as - // query expansion is needed. For example, if a query does not have enough - // results, an expanded query with - // [SearchRequest.canonical_filter][google.cloud.retail.v2alpha.SearchRequest.canonical_filter] - // will be returned as a supplement of the original query. This field is - // strongly recommended to achieve high search quality. - // - // See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for more details about filter syntax. - string canonical_filter = 28; - - // The order in which products are returned. Products can be ordered by - // a field in an [Product][google.cloud.retail.v2alpha.Product] object. Leave - // it unset if ordered by relevance. OrderBy expression is case-sensitive. See - // more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#order). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string order_by = 11; - - // Facet specifications for faceted search. If empty, no facets are returned. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated FacetSpec facet_specs = 12; - - // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - // to enable dynamic facets. Do not set this field. - // - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; - - // Boost specification to boost certain products. See more details at this - // [user guide](https://cloud.google.com/retail/docs/boosting). - // - // Notice that if both - // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] - // and [SearchRequest.boost_spec] are set, the boost conditions from both - // places are evaluated. If a search request matches multiple boost - // conditions, the final boost score is equal to the sum of the boost scores - // from all matched boost conditions. - BoostSpec boost_spec = 13; - - // The query expansion specification that specifies the conditions under which - // query expansion will occur. See more details at this [user - // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - QueryExpansionSpec query_expansion_spec = 14; - - // The relevance threshold of the search results. - // - // Defaults to - // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH], - // which means only the most relevant results are shown, and the least number - // of results are returned. See more details at this [user - // guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - RelevanceThreshold relevance_threshold = 15; - - // The keys to fetch and rollup the matching - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s attributes, - // [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo] or - // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s attributes. - // The attributes from all the matching - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s or - // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s are merged - // and de-duplicated. Notice that rollup attributes will lead to extra query - // latency. Maximum number of keys is 30. - // - // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], a - // fulfillment type and a fulfillment ID must be provided in the format of - // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - // "pickupInStore" is fulfillment type and "store123" is the store ID. - // - // Supported keys are: - // - // * colorFamilies - // * price - // * originalPrice - // * discount - // * variantId - // * inventory(place_id,price) - // * inventory(place_id,original_price) - // * inventory(place_id,attributes.key), where key is any key in the - // [Product.inventories.attributes][] map. - // * attributes.key, where key is any key in the - // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes] map. - // * pickupInStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "pickup-in-store". - // * shipToStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "ship-to-store". - // * sameDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "same-day-delivery". - // * nextDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "next-day-delivery". - // * customFulfillment1.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-1". - // * customFulfillment2.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-2". - // * customFulfillment3.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-3". - // * customFulfillment4.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-4". - // * customFulfillment5.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-5". - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - repeated string variant_rollup_keys = 17; - - // The categories associated with a category page. Required for category - // navigation queries to achieve good search quality. The format should be - // the same as - // [UserEvent.page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories]; - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - repeated string page_categories = 23; - - // The search mode of the search request. If not specified, a single search - // request triggers both product search and faceted search. - SearchMode search_mode = 31; - - // The specification for personalization. - PersonalizationSpec personalization_spec = 32; -} - -// Response message for -// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] -// method. -message SearchResponse { - // Represents the search results. - message SearchResult { - // [Product.id][google.cloud.retail.v2alpha.Product.id] of the searched - // [Product][google.cloud.retail.v2alpha.Product]. - string id = 1; - - // The product data snippet in the search response. Only - // [Product.name][google.cloud.retail.v2alpha.Product.name] is guaranteed to - // be populated. - // - // [Product.variants][google.cloud.retail.v2alpha.Product.variants] contains - // the product variants that match the search query. If there are multiple - // product variants matching the query, top 5 most relevant product variants - // are returned and ordered by relevancy. - // - // If relevancy can be deternmined, use - // [matching_variant_fields][google.cloud.retail.v2alpha.SearchResponse.SearchResult.matching_variant_fields] - // to look up matched product variants fields. If relevancy cannot be - // determined, e.g. when searching "shoe" all products in a shoe product can - // be a match, 5 product variants are returned but order is meaningless. - Product product = 2; - - // The count of matched - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s. - int32 matching_variant_count = 3; - - // If a [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] matches the search query, - // this map indicates which [Product][google.cloud.retail.v2alpha.Product] - // fields are matched. The key is the - // [Product.name][google.cloud.retail.v2alpha.Product.name], the value is a - // field mask of the matched [Product][google.cloud.retail.v2alpha.Product] - // fields. If matched attributes cannot be determined, this map will be - // empty. - // - // For example, a key "sku1" with field mask - // "products.color_info" indicates there is a match between - // "sku1" [ColorInfo][google.cloud.retail.v2alpha.ColorInfo] and the query. - map matching_variant_fields = 4; - - // The rollup matching - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] attributes. The key is one - // of the - // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2alpha.SearchRequest.variant_rollup_keys]. - // The values are the merged and de-duplicated - // [Product][google.cloud.retail.v2alpha.Product] attributes. Notice that - // the rollup values are respect filter. For example, when filtering by - // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is - // returned. - // - // For textual and numerical attributes, the rollup values is a list of - // string or double values with type - // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if - // there are two variants with colors "red" and "blue", the rollup values - // are - // - // { key: "colorFamilies" - // value { - // list_value { - // values { string_value: "red" } - // values { string_value: "blue" } - // } - // } - // } - // - // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], the - // rollup values is a double value with type - // [google.protobuf.Value][google.protobuf.Value]. For example, - // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there - // are 10 variants in this product are available in the store "store1". - map variant_rollup_values = 5; - } - - // A facet result. - message Facet { - // A facet value which contains value names and their count. - message FacetValue { - // A facet value which contains values. - oneof facet_value { - // Text value of a facet, such as "Black" for facet "colorFamilies". - string value = 1; - - // Interval value for a facet, such as [10, 20) for facet "price". - Interval interval = 2; - } - - // Number of items that have this facet value. - int64 count = 3; - } - - // The key for this facet. E.g., "colorFamilies" or "price" or - // "attributes.attr1". - string key = 1; - - // The facet values for this field. - repeated FacetValue values = 2; - - // Whether the facet is dynamically generated. - bool dynamic_facet = 3; - } - - // Information describing query expansion including whether expansion has - // occurred. - message QueryExpansionInfo { - // Bool describing whether query expansion has occurred. - bool expanded_query = 1; - - // Number of pinned results. This field will only be set when expansion - // happens and - // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] - // is set to true. - int64 pinned_result_count = 2; - } - - // A list of matched items. The order represents the ranking. - repeated SearchResult results = 1; - - // Results of facets requested by user. - repeated Facet facets = 2; - - // The estimated total count of matched items irrespective of pagination. The - // count of [results][google.cloud.retail.v2alpha.SearchResponse.results] - // returned by pagination may be less than the - // [total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] that - // matches. - int32 total_size = 3; - - // If spell correction applies, the corrected query. Otherwise, empty. - string corrected_query = 4; - - // A unique search token. This should be included in the - // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this - // search, which enables accurate attribution of search model performance. - string attribution_token = 5; - - // A token that can be sent as - // [SearchRequest.page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 6; - - // Query expansion information for the returned results. - QueryExpansionInfo query_expansion_info = 7; - - // The URI of a customer-defined redirect page. If redirect action is - // triggered, no search will be performed, and only - // [redirect_uri][google.cloud.retail.v2alpha.SearchResponse.redirect_uri] and - // [attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] - // will be set in the response. - string redirect_uri = 10; - - // The fully qualified resource name of applied - // [controls](https://cloud.google.com/retail/docs/serving-control-rules). - repeated string applied_controls = 12; - - // The invalid - // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] - // that are not applied during serving. - repeated SearchRequest.BoostSpec.ConditionBoostSpec - invalid_condition_boost_specs = 14; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto deleted file mode 100644 index c339f310..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/search_service.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Configures metadata that is used to generate serving time results (e.g. -// search results or recommendation predictions). -// The ServingConfig is passed in the search and predict request and together -// with the Catalog.default_branch, generates results. -message ServingConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/ServingConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" - }; - - // Immutable. Fully qualified name - // projects/*/locations/global/catalogs/*/servingConfig/* - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. The human readable serving config display name. Used in Retail - // UI. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // The id of the model to use at serving time. - // Currently only RecommendationModels are supported: - // https://cloud.google.com/retail/recommendations-ai/docs/create-models - // Can be changed but only to a compatible model (e.g. - // others-you-may-like CTR to others-you-may-like CVR). - // - // Required when - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string model_id = 3; - - // How much price ranking we want in serving results. - // Price reranking causes product items with a similar - // recommendation probability to be ordered by price, with the - // highest-priced items first. This setting could result in a decrease in - // click-through and conversion rates. - // Allowed values are: - // - // * 'no-price-reranking' - // * 'low-price-raranking' - // * 'medium-price-reranking' - // * 'high-price-reranking' - // - // If not specified, we choose default based on model type. Default value: - // 'no-price-reranking'. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string price_reranking_level = 4; - - // Facet specifications for faceted search. If empty, no facets are returned. - // The ids refer to the ids of [Control][google.cloud.retail.v2alpha.Control] - // resources with only the Facet control set. These controls are assumed to be - // in the same [Catalog][google.cloud.retail.v2alpha.Catalog] as the - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]. - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string facet_control_ids = 5; - - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; - - // Condition boost specifications. If a product matches multiple conditions - // in the specifications, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 100. - // - // Notice that if both - // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] - // and [SearchRequest.boost_spec] are set, the boost conditions from both - // places are evaluated. If a search request matches multiple boost - // conditions, the final boost score is equal to the sum of the boost scores - // from all matched boost conditions. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string boost_control_ids = 7; - - // Condition filter specifications. If a product matches multiple conditions - // in the specifications, filters from these specifications are all - // applied and combined via the AND operator. Maximum number of - // specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string filter_control_ids = 9; - - // Condition redirect specifications. Only the first triggered redirect action - // is applied, even if multiple apply. Maximum number of specifications is - // 1000. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string redirect_control_ids = 10; - - // Condition synonyms specifications. If multiple syonyms conditions match, - // all matching synonyms control in the list will execute. Order of controls - // in the list will not matter. Maximum number of specifications is - // 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string twoway_synonyms_control_ids = 18; - - // Condition oneway synonyms specifications. If multiple oneway synonyms - // conditions match, all matching oneway synonyms controls in the list will - // execute. Order of controls in the list will not matter. Maximum number of - // specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string oneway_synonyms_control_ids = 12; - - // Condition do not associate specifications. If multiple do not associate - // conditions match, all matching do not associate controls in the list will - // execute. - // - Order does not matter. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string do_not_associate_control_ids = 13; - - // Condition replacement specifications. - // - Applied according to the order in the list. - // - A previously replaced term can not be re-replaced. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string replacement_control_ids = 14; - - // Condition ignore specifications. If multiple ignore - // conditions match, all matching ignore controls in the list will - // execute. - // - Order does not matter. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string ignore_control_ids = 15; - - // How much diversity to use in recommendation model results e.g. - // 'medium-diversity' or 'high-diversity'. Currently supported values: - // - // * 'no-diversity' - // * 'low-diversity' - // * 'medium-diversity' - // * 'high-diversity' - // * 'auto-diversity' - // - // If not specified, we choose default based on recommendation model - // type. Default value: 'no-diversity'. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string diversity_level = 8; - - // Whether to add additional category filters on the 'similar-items' model. - // If not specified, we enable it by default. - // Allowed values are: - // - // * 'no-category-match': No additional filtering of original results from - // the model and the customer's filters. - // * 'relaxed-category-match': Only keep results with categories that match - // at least one item categories in the PredictRequests's context item. - // * If customer also sends filters in the PredictRequest, then the results - // will satisfy both conditions (user given and category match). - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string enable_category_filter_level = 16; - - // Required. Immutable. Specifies the solution types that a serving config can - // be associated with. Currently we support setting only one type of solution. - repeated SolutionType solution_types = 19 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto deleted file mode 100644 index 48286797..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/serving_config.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for modifying ServingConfig. -service ServingConfigService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a ServingConfig. - // - // A maximum of 100 - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in - // a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a - // FAILED_PRECONDITION error is returned. - rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" - body: "serving_config" - }; - option (google.api.method_signature) = - "parent,serving_config,serving_config_id"; - } - - // Deletes a ServingConfig. - // - // Returns a NotFound error if the ServingConfig does not exist. - rpc DeleteServingConfig(DeleteServingConfigRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a ServingConfig. - rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - patch: "/v2alpha/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - body: "serving_config" - }; - option (google.api.method_signature) = "serving_config,update_mask"; - } - - // Gets a ServingConfig. - // - // Returns a NotFound error if the ServingConfig does not exist. - rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all ServingConfigs linked to this catalog. - rpc ListServingConfigs(ListServingConfigsRequest) - returns (ListServingConfigsResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" - }; - option (google.api.method_signature) = "parent"; - } - - // Enables a Control on the specified ServingConfig. - // The control is added in the last position of the list of controls - // it belongs to (e.g. if it's a facet spec control it will be applied - // in the last position of servingConfig.facetSpecIds) - // Returns a ALREADY_EXISTS error if the control has already been applied. - // Returns a FAILED_PRECONDITION error if the addition could exceed maximum - // number of control allowed for that type of control. - rpc AddControl(AddControlRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" - body: "*" - }; - option (google.api.method_signature) = "serving_config"; - } - - // Disables a Control on the specified ServingConfig. - // The control is removed from the ServingConfig. - // Returns a NOT_FOUND error if the Control is not enabled for the - // ServingConfig. - rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" - body: "*" - }; - option (google.api.method_signature) = "serving_config"; - } -} - -// Request for CreateServingConfig method. -message CreateServingConfigRequest { - // Required. Full resource name of parent. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The ServingConfig to create. - ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the ServingConfig, which will become the final - // component of the ServingConfig's resource name. - // - // This value should be 4-63 characters, and valid characters - // are /[a-z][0-9]-_/. - string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for UpdateServingConfig method. -message UpdateServingConfigRequest { - // Required. The ServingConfig to update. - ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to update. The - // following are NOT supported: - // - // * [ServingConfig.name][google.cloud.retail.v2alpha.ServingConfig.name] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for DeleteServingConfig method. -message DeleteServingConfigRequest { - // Required. The resource name of the ServingConfig to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; -} - -// Request for GetServingConfig method. -message GetServingConfigRequest { - // Required. The resource name of the ServingConfig to get. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; -} - -// Request for ListServingConfigs method. -message ListServingConfigsRequest { - // Required. The catalog resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Optional. Maximum number of results to return. If unspecified, defaults - // to 100. If a value greater than 100 is provided, at most 100 results are - // returned. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListServingConfigs` call. - // Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for ListServingConfigs method. -message ListServingConfigsResponse { - // All the ServingConfigs for a given catalog. - repeated ServingConfig serving_configs = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} - -// Request for AddControl method. -message AddControlRequest { - // Required. The source ServingConfig resource name . Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; - - // Required. The id of the control to apply. Assumed to be in the same catalog - // as the serving config - if id is not found a NOT_FOUND error is returned. - string control_id = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for RemoveControl method. -message RemoveControlRequest { - // Required. The source ServingConfig resource name . Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; - - // Required. The id of the control to apply. Assumed to be in the same catalog - // as the serving config. - string control_id = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto deleted file mode 100644 index 94f72879..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/product.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// UserEvent captures all metadata information Retail API needs to know about -// how end users interact with customers' website. -message UserEvent { - // Required. User event type. Allowed values are: - // - // * `add-to-cart`: Products being added to cart. - // * `category-page-view`: Special pages such as sale or promotion pages - // viewed. - // * `detail-page-view`: Products detail page viewed. - // * `home-page-view`: Homepage viewed. - // * `promotion-offered`: Promotion is offered to a user. - // * `promotion-not-offered`: Promotion is not offered to a user. - // * `purchase-complete`: User finishing a purchase. - // * `search`: Product search. - // * `shopping-cart-page-view`: User viewing a shopping cart. - string event_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A unique identifier for tracking visitors. - // - // For example, this could be implemented with an HTTP cookie, which should be - // able to uniquely identify a visitor on a single device. This unique - // identifier should not change if the visitor log in/out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // The field should not contain PII or user-data. We recommend to use Google - // Analystics [Client - // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) - // for this field. - string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // A unique identifier for tracking a visitor session with a length limit of - // 128 bytes. A session is an aggregation of an end user behavior in a time - // span. - // - // A general guideline to populate the sesion_id: - // 1. If user has no activity for 30 min, a new session_id should be assigned. - // 2. The session_id should be unique across users, suggest use uuid or add - // visitor_id as prefix. - string session_id = 21; - - // Only required for - // [UserEventService.ImportUserEvents][google.cloud.retail.v2alpha.UserEventService.ImportUserEvents] - // method. Timestamp of when the user event happened. - google.protobuf.Timestamp event_time = 3; - - // A list of identifiers for the independent experiment groups this user event - // belongs to. This is used to distinguish between user events associated with - // different experiment setups (e.g. using Retail API, using different - // recommendation models). - repeated string experiment_ids = 4; - - // Highly recommended for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. - // This field enables accurate attribution of recommendation model - // performance. - // - // The value must be a valid - // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] - // for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. - // The value must be a valid - // [SearchResponse.attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] - // for user events that are the result of - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // This token enables us to accurately attribute page view or purchase back to - // the event and the particular predict response containing this - // clicked/purchased product. If user clicks on product K in the - // recommendation results, pass - // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] - // as a URL parameter to product K's page. When recording events on product - // K's page, log the - // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] - // to this field. - string attribution_token = 5; - - // The main product details related to the event. - // - // This field is required for the following event types: - // - // * `add-to-cart` - // * `detail-page-view` - // * `purchase-complete` - // * `search` - // - // In a `search` event, this field represents the products returned to the end - // user on the current page (the end user may have not finished browsing the - // whole page yet). When a new page is returned to the end user, after - // pagination/filtering/ordering even for the same query, a new `search` event - // with different - // [product_details][google.cloud.retail.v2alpha.UserEvent.product_details] is - // desired. The end user may have not finished browsing the whole page yet. - repeated ProductDetail product_details = 6; - - // The main auto-completion details related to the event. - // - // This field should be set for `search` event when autocomplete function is - // enabled and the user clicks a suggestion for search. - CompletionDetail completion_detail = 22; - - // Extra user event features to include in the recommendation model. - // - // If you provide custom attributes for ingested user events, also include - // them in the user events that you associate with prediction requests. Custom - // attribute formatting must be consistent between imported events and events - // provided with prediction requests. This lets the Retail API use - // those custom attributes when training models and serving predictions, which - // helps improve recommendation quality. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * The key must be a UTF-8 encoded string with a length limit of 5,000 - // characters. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 256 characters. - // * For number attributes, at most 400 values are allowed. - // - // For product recommendations, an example of extra user information is - // traffic_channel, which is how a user arrives at the site. Users can arrive - // at the site by coming to the site directly, coming through Google - // search, or in other ways. - map attributes = 7; - - // The ID or name of the associated shopping cart. This ID is used - // to associate multiple items added or present in the cart before purchase. - // - // This can only be set for `add-to-cart`, `purchase-complete`, or - // `shopping-cart-page-view` events. - string cart_id = 8; - - // A transaction represents the entire purchase transaction. - // - // Required for `purchase-complete` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - PurchaseTransaction purchase_transaction = 9; - - // The user's search query. - // - // See [SearchRequest.query][google.cloud.retail.v2alpha.SearchRequest.query] - // for definition. - // - // The value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // At least one of - // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - string search_query = 10; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. - // - // See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string filter = 16; - - // The order in which products are returned. - // - // See - // [SearchRequest.order_by][google.cloud.retail.v2alpha.SearchRequest.order_by] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string order_by = 17; - - // An integer that specifies the current offset for pagination (the 0-indexed - // starting location, amongst the products deemed by the API as relevant). - // - // See - // [SearchRequest.offset][google.cloud.retail.v2alpha.SearchRequest.offset] - // for definition. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - int32 offset = 18; - - // The categories associated with a category page. - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - // - // Required for `category-page-view` events. At least one of - // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated string page_categories = 11; - - // User information. - UserInfo user_info = 12; - - // Complete URL (window.location.href) of the user's current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. Maximum length 5,000 - // characters. - string uri = 13; - - // The referrer URL of the current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string referrer_uri = 14; - - // A unique ID of a web page view. - // - // This should be kept the same for all user events triggered from the same - // pageview. For example, an item detail page view could trigger multiple - // events as the user is browsing the page. The `pageViewId` property should - // be kept the same for all these events so that they can be grouped together - // properly. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string page_view_id = 15; -} - -// Detailed product information associated with a user event. -message ProductDetail { - // Required. [Product][google.cloud.retail.v2alpha.Product] information. - // - // Required field(s): - // - // * [Product.id][google.cloud.retail.v2alpha.Product.id] - // - // Optional override field(s): - // - // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] - // - // If any supported optional fields are provided, we will treat them as a full - // override when looking up product information from the catalog. Thus, it is - // important to ensure that the overriding fields are accurate and - // complete. - // - // All other product fields are ignored and instead populated via catalog - // lookup after event ingestion. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Quantity of the product associated with the user event. - // - // For example, this field will be 2 if two products are added to the shopping - // cart for `purchase-complete` event. Required for `add-to-cart` and - // `purchase-complete` event types. - google.protobuf.Int32Value quantity = 2; -} - -// Detailed completion information including completion attribution token and -// clicked completion info. -message CompletionDetail { - // Completion attribution token in - // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2alpha.CompleteQueryResponse.attribution_token]. - string completion_attribution_token = 1; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion]. - string selected_suggestion = 2; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion] - // position, starting from 0. - int32 selected_position = 3; -} - -// A transaction represents the entire purchase transaction. -message PurchaseTransaction { - // The transaction ID with a length limit of 128 characters. - string id = 1; - - // Required. Total non-zero revenue or grand total associated with the - // transaction. This value include shipping, tax, or other adjustments to - // total revenue that you want to include as part of your revenue - // calculations. - float revenue = 2 [(google.api.field_behavior) = REQUIRED]; - - // All the taxes associated with the transaction. - float tax = 3; - - // All the costs associated with the products. These can be manufacturing - // costs, shipping expenses not borne by the end user, or any other costs, - // such that: - // - // * Profit = - // [revenue][google.cloud.retail.v2alpha.PurchaseTransaction.revenue] - - // [tax][google.cloud.retail.v2alpha.PurchaseTransaction.tax] - - // [cost][google.cloud.retail.v2alpha.PurchaseTransaction.cost] - float cost = 4; - - // Required. Currency code. Use three-character ISO-4217 code. - string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto deleted file mode 100644 index af97dad9..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/httpbody.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/import_config.proto"; -import "google/cloud/retail/v2alpha/purge_config.proto"; -import "google/cloud/retail/v2alpha/user_event.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for ingesting end user actions on the customer website. -service UserEventService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Writes a single user event. - rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" - body: "user_event" - }; - } - - // Writes a single user event from the browser. This uses a GET request to - // due to browser restriction of POST-ing to a 3rd party domain. - // - // This method is used only by the Retail API JavaScript pixel and Google Tag - // Manager. Users should not call this method directly. - rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" - }; - } - - // Deletes permanently all user events specified by the filter provided. - // Depending on the number of events specified by the filter, this operation - // could take hours or days to complete. To test a filter, use the list - // command first. - rpc PurgeUserEvents(PurgeUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.PurgeUserEventsResponse" - metadata_type: "google.cloud.retail.v2alpha.PurgeMetadata" - }; - } - - // Bulk import of User events. Request processing might be - // synchronous. Events that already exist are skipped. - // Use this method for backfilling historical user events. - // - // Operation.response is of type ImportResponse. Note that it is - // possible for a subset of the items to be successfully inserted. - // Operation.metadata is of type ImportMetadata. - rpc ImportUserEvents(ImportUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.ImportUserEventsResponse" - metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" - }; - } - - // Starts a user event rejoin operation with latest product catalog. Events - // will not be annotated with detailed product information if product is - // missing from the catalog at the time the user event is ingested, and these - // events are stored as unjoined events with a limited usage on training and - // serving. This method can be used to start a join operation on specified - // events with latest version of product catalog. It can also be used to - // correct events joined with the wrong product catalog. A rejoin operation - // can take hours or days to complete. - rpc RejoinUserEvents(RejoinUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "RejoinUserEventsResponse" - metadata_type: "RejoinUserEventsMetadata" - }; - } -} - -// Request message for WriteUserEvent method. -message WriteUserEventRequest { - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User event to write. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // Required. The parent catalog name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. URL encoded UserEvent proto with a length limit of 2,000,000 - // characters. - string user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // The URL including cgi-parameters but excluding the hash fragment with a - // length limit of 5,000 characters. This is often more useful than the - // referer URL, because many browsers only send the domain for 3rd party - // requests. - string uri = 3; - - // The event timestamp in milliseconds. This prevents browser caching of - // otherwise identical get requests. The name is abbreviated to reduce the - // payload bytes. - int64 ets = 4; -} - -// Request message for RejoinUserEvents method. -message RejoinUserEventsRequest { - // The scope of user events to be rejoined with the latest product catalog. - // If the rejoining aims at reducing number of unjoined events, set - // UserEventRejoinScope to UNJOINED_EVENTS. - // If the rejoining aims at correcting product catalog information in joined - // events, set UserEventRejoinScope to JOINED_EVENTS. - // If all events needs to be rejoined, set UserEventRejoinScope to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. - enum UserEventRejoinScope { - // Rejoin all events with the latest product catalog, including both joined - // events and unjoined events. - USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; - - // Only rejoin joined events with the latest product catalog. - JOINED_EVENTS = 1; - - // Only rejoin unjoined events with the latest product catalog. - UNJOINED_EVENTS = 2; - } - - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The type of the user event rejoin to define the scope and range of the user - // events to be rejoined with the latest product catalog. Defaults to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - // invalid integer value. - UserEventRejoinScope user_event_rejoin_scope = 2; -} - -// Response message for RejoinUserEvents method. -message RejoinUserEventsResponse { - // Number of user events that were joined with latest product catalog. - int64 rejoined_user_events_count = 1; -} - -// Metadata for RejoinUserEvents method. -message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js deleted file mode 100644 index 0a46b0bb..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(attributesConfig, catalogAttribute) { - // [START retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The - * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to add. - */ - // const catalogAttribute = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callAddCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - catalogAttribute, - }; - - // Run request - const response = await retailClient.addCatalogAttribute(request); - console.log(response); - } - - callAddCatalogAttribute(); - // [END retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js deleted file mode 100644 index 8fe314bf..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_CatalogService_GetAttributesConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const name = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetAttributesConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getAttributesConfig(request); - console.log(response); - } - - callGetAttributesConfig(); - // [END retail_v2alpha_generated_CatalogService_GetAttributesConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js deleted file mode 100644 index b189f66e..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_CatalogService_GetCompletionConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full CompletionConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - */ - // const name = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetCompletionConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getCompletionConfig(request); - console.log(response); - } - - callGetCompletionConfig(); - // [END retail_v2alpha_generated_CatalogService_GetCompletionConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js deleted file mode 100644 index 075a2b10..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2alpha_generated_CatalogService_GetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.getDefaultBranch(request); - console.log(response); - } - - callGetDefaultBranch(); - // [END retail_v2alpha_generated_CatalogService_GetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js deleted file mode 100644 index 2bed2f3f..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2alpha_generated_CatalogService_ListCatalogs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The account resource name with an associated location. - * If the caller does not have permission to list - * Catalog google.cloud.retail.v2alpha.Catalog s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Catalog google.cloud.retail.v2alpha.Catalog s to - * return. If unspecified, defaults to 50. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListCatalogsResponse.next_page_token google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token, - * received from a previous - * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callListCatalogs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listCatalogsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCatalogs(); - // [END retail_v2alpha_generated_CatalogService_ListCatalogs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js deleted file mode 100644 index 81358df9..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(attributesConfig, key) { - // [START retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The attribute name key of the - * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to remove. - */ - // const key = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callRemoveCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - key, - }; - - // Run request - const response = await retailClient.removeCatalogAttribute(request); - console.log(response); - } - - callRemoveCatalogAttribute(); - // [END retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js deleted file mode 100644 index 2fdfc582..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.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(attributesConfig, catalogAttribute) { - // [START retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The updated - * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute. - */ - // const catalogAttribute = {} - /** - * Indicates which fields in the provided - * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to update. - * The following are NOT supported: - * * CatalogAttribute.key google.cloud.retail.v2alpha.CatalogAttribute.key - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callReplaceCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - catalogAttribute, - }; - - // Run request - const response = await retailClient.replaceCatalogAttribute(request); - console.log(response); - } - - callReplaceCatalogAttribute(); - // [END retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js deleted file mode 100644 index 7fce54ef..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2alpha_generated_CatalogService_SetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * The final component of the resource name of a branch. - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * If there are no sufficient active products in the targeted branch and - * force google.cloud.retail.v2alpha.SetDefaultBranchRequest.force is not - * set, a FAILED_PRECONDITION error is returned. - */ - // const branchId = 'abc123' - /** - * Some note on this request, this can be retrieved by - * CatalogService.GetDefaultBranch google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch - * before next valid default branch set occurs. - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const note = 'abc123' - /** - * If set to true, it permits switching to a branch with - * branch_id google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id - * even if it has no sufficient active products. - */ - // const force = true - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callSetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.setDefaultBranch(request); - console.log(response); - } - - callSetDefaultBranch(); - // [END retail_v2alpha_generated_CatalogService_SetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js deleted file mode 100644 index bf5828a2..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.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(attributesConfig) { - // [START retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The - * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. - */ - // const attributesConfig = {} - /** - * Indicates which fields in the provided - * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. - * The following is the only supported field: - * * AttributesConfig.catalog_attributes google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateAttributesConfig() { - // Construct request - const request = { - attributesConfig, - }; - - // Run request - const response = await retailClient.updateAttributesConfig(request); - console.log(response); - } - - callUpdateAttributesConfig(); - // [END retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js deleted file mode 100644 index 81ee698f..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.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(catalog) { - // [START retail_v2alpha_generated_CatalogService_UpdateCatalog_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Catalog google.cloud.retail.v2alpha.Catalog to update. - * If the caller does not have permission to update the - * Catalog google.cloud.retail.v2alpha.Catalog, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * If the Catalog google.cloud.retail.v2alpha.Catalog to update does not - * exist, a NOT_FOUND error is returned. - */ - // const catalog = {} - /** - * Indicates which fields in the provided - * Catalog google.cloud.retail.v2alpha.Catalog to update. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCatalog() { - // Construct request - const request = { - catalog, - }; - - // Run request - const response = await retailClient.updateCatalog(request); - console.log(response); - } - - callUpdateCatalog(); - // [END retail_v2alpha_generated_CatalogService_UpdateCatalog_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js deleted file mode 100644 index 62e6eea3..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.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(completionConfig) { - // [START retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The - * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. - * If the caller does not have permission to update the - * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig, then a - * PERMISSION_DENIED error is returned. - * If the CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to - * update does not exist, a NOT_FOUND error is returned. - */ - // const completionConfig = {} - /** - * Indicates which fields in the provided - * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. - * The following are the only supported fields: - * * CompletionConfig.matching_order google.cloud.retail.v2alpha.CompletionConfig.matching_order - * * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions - * * CompletionConfig.min_prefix_length google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length - * * CompletionConfig.auto_learning google.cloud.retail.v2alpha.CompletionConfig.auto_learning - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCompletionConfig() { - // Construct request - const request = { - completionConfig, - }; - - // Run request - const response = await retailClient.updateCompletionConfig(request); - console.log(response); - } - - callUpdateCompletionConfig(); - // [END retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js deleted file mode 100644 index 6f768b76..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(catalog, query) { - // [START retail_v2alpha_generated_CompletionService_CompleteQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Catalog for which the completion is performed. - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * Required. The query used to generate suggestions. - * The maximum number of allowed characters is 255. - */ - // const query = 'abc123' - /** - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see Tags for - * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - */ - // const languageCodes = 'abc123' - /** - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * Supported formats: - * * `UNKNOWN_DEVICE_TYPE` - * * `DESKTOP` - * * `MOBILE` - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - */ - // const deviceType = 'abc123' - /** - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * CompletionService.ImportCompletionData google.cloud.retail.v2alpha.CompletionService.ImportCompletionData. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * Current supported values: - * * user-data - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - */ - // const dataset = 'abc123' - /** - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value - * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions. - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - */ - // const maxSuggestions = 1234 - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callCompleteQuery() { - // Construct request - const request = { - catalog, - query, - }; - - // Run request - const response = await retailClient.completeQuery(request); - console.log(response); - } - - callCompleteQuery(); - // [END retail_v2alpha_generated_CompletionService_CompleteQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js deleted file mode 100644 index b54422e5..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.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, inputConfig) { - // [START retail_v2alpha_generated_CompletionService_ImportCompletionData_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog which the suggestions dataset belongs to. - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callImportCompletionData() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importCompletionData(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportCompletionData(); - // [END retail_v2alpha_generated_CompletionService_ImportCompletionData_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js deleted file mode 100644 index bacd422a..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.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, control, controlId) { - // [START retail_v2alpha_generated_ControlService_CreateControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of parent catalog. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Required. The Control to create. - */ - // const control = {} - /** - * Required. The ID to use for the Control, which will become the final - * component of the Control's resource name. - * This value should be 4-63 characters, and valid characters - * are /[a-z][0-9]-_/. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callCreateControl() { - // Construct request - const request = { - parent, - control, - controlId, - }; - - // Run request - const response = await retailClient.createControl(request); - console.log(response); - } - - callCreateControl(); - // [END retail_v2alpha_generated_ControlService_CreateControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js deleted file mode 100644 index 6afa1e03..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ControlService_DeleteControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callDeleteControl() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteControl(request); - console.log(response); - } - - callDeleteControl(); - // [END retail_v2alpha_generated_ControlService_DeleteControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js deleted file mode 100644 index a0c4c927..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ControlService_GetControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callGetControl() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getControl(request); - console.log(response); - } - - callGetControl(); - // [END retail_v2alpha_generated_ControlService_GetControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js deleted file mode 100644 index c09815fd..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2alpha_generated_ControlService_ListControls_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - /** - * Optional. A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2alpha.ListControlsRequest.filter is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - */ - // const filter = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callListControls() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listControlsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListControls(); - // [END retail_v2alpha_generated_ControlService_ListControls_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js deleted file mode 100644 index 7f0e4c67..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(control) { - // [START retail_v2alpha_generated_ControlService_UpdateControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Control to update. - */ - // const control = {} - /** - * Indicates which fields in the provided - * Control google.cloud.retail.v2alpha.Control to update. The following are - * NOT supported: - * * Control.name google.cloud.retail.v2alpha.Control.name - * If not set or empty, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callUpdateControl() { - // Construct request - const request = { - control, - }; - - // Run request - const response = await retailClient.updateControl(request); - console.log(response); - } - - callUpdateControl(); - // [END retail_v2alpha_generated_ControlService_UpdateControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js deleted file mode 100644 index f49c45f1..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, userEvent) { - // [START retail_v2alpha_generated_PredictionService_Predict_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see Managing - * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - */ - // const placement = 'abc123' - /** - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - */ - // const userEvent = {} - /** - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - */ - // const pageSize = 1234 - /** - * The previous PredictResponse.next_page_token. - */ - // const pageToken = 'abc123' - /** - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * Examples: - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - */ - // const filter = 'abc123' - /** - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - */ - // const validateOnly = true - /** - * Additional domain specific parameters for the predictions. - * Allowed values: - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - */ - // const params = 1234 - /** - * The labels applied to a resource must meet the following requirements: - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * See Google Cloud - * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - */ - // const labels = 1234 - - // Imports the Retail library - const {PredictionServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new PredictionServiceClient(); - - async function callPredict() { - // Construct request - const request = { - placement, - userEvent, - }; - - // Run request - const response = await retailClient.predict(request); - console.log(response); - } - - callPredict(); - // [END retail_v2alpha_generated_PredictionService_Predict_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js deleted file mode 100644 index c15b5aa0..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type, such - * as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type. - * Duplicate IDs will be automatically ignored. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * If the total number of place IDs exceeds 2000 for this - * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type after - * adding, then the update will be rejected. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * Product google.cloud.retail.v2alpha.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddFulfillmentPlaces(); - // [END retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js deleted file mode 100644 index 1a0bcb74..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, localInventories) { - // [START retail_v2alpha_generated_ProductService_AddLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - */ - // const localInventories = 1234 - /** - * Indicates which inventory fields in the provided list of - * LocalInventory google.cloud.retail.v2alpha.LocalInventory to update. The - * field is updated to the provided value. - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const addMask = {} - /** - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, the local inventory will still be processed and retained for at - * most 1 day and processed once the - * Product google.cloud.retail.v2alpha.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddLocalInventories() { - // Construct request - const request = { - product, - localInventories, - }; - - // Run request - const [operation] = await retailClient.addLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddLocalInventories(); - // [END retail_v2alpha_generated_ProductService_AddLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js deleted file mode 100644 index d452aae4..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, product, productId) { - // [START retail_v2alpha_generated_ProductService_CreateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - */ - // const parent = 'abc123' - /** - * Required. The Product google.cloud.retail.v2alpha.Product to create. - */ - // const product = {} - /** - * Required. The ID to use for the - * Product google.cloud.retail.v2alpha.Product, which will become the final - * component of the Product.name google.cloud.retail.v2alpha.Product.name. - * If the caller does not have permission to create the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * This field must be unique among all - * Product google.cloud.retail.v2alpha.Product s with the same - * parent google.cloud.retail.v2alpha.CreateProductRequest.parent. - * Otherwise, an ALREADY_EXISTS error is returned. - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const productId = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - productId, - }; - - // Run request - const response = await retailClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END retail_v2alpha_generated_ProductService_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js deleted file mode 100644 index 7470b33d..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_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(name) { - // [START retail_v2alpha_generated_ProductService_DeleteProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to delete the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2alpha.Product to delete does not - * exist, a NOT_FOUND error is returned. - * The Product google.cloud.retail.v2alpha.Product to delete can neither be - * a - * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION - * Product google.cloud.retail.v2alpha.Product member nor a - * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY - * Product google.cloud.retail.v2alpha.Product with more than one - * variants google.cloud.retail.v2alpha.Product.Type.VARIANT. Otherwise, an - * INVALID_ARGUMENT error is returned. - * All inventory information for the named - * Product google.cloud.retail.v2alpha.Product will be deleted. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END retail_v2alpha_generated_ProductService_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js deleted file mode 100644 index 52340240..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ProductService_GetProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * If the requested Product google.cloud.retail.v2alpha.Product does not - * exist, a NOT_FOUND error is returned. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END retail_v2alpha_generated_ProductService_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js deleted file mode 100644 index 26a70a51..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2alpha_generated_ProductService_ImportProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. - */ - // const errorsConfig = {} - /** - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - */ - // const updateMask = {} - /** - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * ReconciliationMode.INCREMENTAL google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL. - */ - // const reconciliationMode = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * Only supported when - * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode - * is set to `FULL`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callImportProducts() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProducts(); - // [END retail_v2alpha_generated_ProductService_ImportProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js deleted file mode 100644 index a9e1ed2f..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2alpha_generated_ProductService_ListProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * If the caller does not have permission to list - * Product google.cloud.retail.v2alpha.Product s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Product google.cloud.retail.v2alpha.Product s to - * return. If unspecified, defaults to 100. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT error is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListProductsResponse.next_page_token google.cloud.retail.v2alpha.ListProductsResponse.next_page_token, - * received from a previous - * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2alpha.ListProductsRequest.filter is unset. - * * List - * Product.Type.VARIANT google.cloud.retail.v2alpha.Product.Type.VARIANT - * Product google.cloud.retail.v2alpha.Product s sharing the same - * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY - * Product google.cloud.retail.v2alpha.Product. For example: - * `primary_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2alpha.Product s bundled in a - * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION - * Product google.cloud.retail.v2alpha.Product. - * For example: - * `collection_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2alpha.Product s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * If the specified - * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY - * Product google.cloud.retail.v2alpha.Product or - * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION - * Product google.cloud.retail.v2alpha.Product does not exist, a NOT_FOUND - * error is returned. - */ - // const filter = 'abc123' - /** - * The fields of Product google.cloud.retail.v2alpha.Product to return in - * the responses. If not set or empty, the following fields are returned: - * * Product.name google.cloud.retail.v2alpha.Product.name - * * Product.id google.cloud.retail.v2alpha.Product.id - * * Product.title google.cloud.retail.v2alpha.Product.title - * * Product.uri google.cloud.retail.v2alpha.Product.uri - * * Product.images google.cloud.retail.v2alpha.Product.images - * * Product.price_info google.cloud.retail.v2alpha.Product.price_info - * * Product.brands google.cloud.retail.v2alpha.Product.brands - * If "*" is provided, all fields are returned. - * Product.name google.cloud.retail.v2alpha.Product.name is always returned - * no matter what mask is set. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const readMask = {} - /** - * If true and - * page_token google.cloud.retail.v2alpha.ListProductsRequest.page_token is - * empty, - * ListProductsResponse.total_size google.cloud.retail.v2alpha.ListProductsResponse.total_size - * is set to the total count of matched items irrespective of pagination. - * Notice that setting this field to true affects the performance. - */ - // const requireTotalSize = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END retail_v2alpha_generated_ProductService_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js deleted file mode 100644 index 55d09aef..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, filter) { - // [START retail_v2alpha_generated_ProductService_PurgeProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the branch under which the products are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` - */ - // const parent = 'abc123' - /** - * Required. The filter string to specify the products to be deleted with a - * length limit of 5,000 characters. - * Empty string filter is not allowed. "*" implies delete all items in a - * branch. - * The eligible fields for filtering are: - * * `availability`: Double quoted - * Product.availability google.cloud.retail.v2alpha.Product.availability - * string. - * * `create_time` : in ISO 8601 "zulu" format. - * Supported syntax: - * * Comparators (">", "<", ">=", "<=", "="). - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" - * * availability = "IN_STOCK" - * * Conjunctions ("AND") - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" - * * Disjunctions ("OR") - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" - * * Can support nested queries. - * Examples: - * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") - * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") - * * Filter Limits: - * * Filter should not contain more than 6 conditions. - * * Max nesting depth should not exceed 2 levels. - * Examples queries: - * * Delete back order products created before a timestamp. - * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" - */ - // const filter = 'abc123' - /** - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any products. - */ - // const force = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await retailClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END retail_v2alpha_generated_ProductService_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js deleted file mode 100644 index 9543acde..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type, - * such as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * Product google.cloud.retail.v2alpha.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveFulfillmentPlaces(); - // [END retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js deleted file mode 100644 index 903fe738..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, placeIds) { - // [START retail_v2alpha_generated_ProductService_RemoveLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - */ - // const placeIds = 'abc123' - /** - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * Product google.cloud.retail.v2alpha.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveLocalInventories() { - // Construct request - const request = { - product, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveLocalInventories(); - // [END retail_v2alpha_generated_ProductService_RemoveLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js deleted file mode 100644 index 00d04376..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js +++ /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 -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(inventory) { - // [START retail_v2alpha_generated_ProductService_SetInventory_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The inventory information to update. The allowable fields to - * update are: - * * Product.price_info google.cloud.retail.v2alpha.Product.price_info - * * Product.availability google.cloud.retail.v2alpha.Product.availability - * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info - * The updated inventory fields must be specified in - * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask. - * If SetInventoryRequest.inventory.name is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2alpha.Product named in - * Product.name google.cloud.retail.v2alpha.Product.name, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2alpha.Product to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * If the Product google.cloud.retail.v2alpha.Product to update has - * existing inventory information, the provided inventory information will be - * merged while respecting the last update time for each inventory field, - * using the provided or default value for - * SetInventoryRequest.set_time google.cloud.retail.v2alpha.SetInventoryRequest.set_time. - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in SetInventoryRequest.inventory.fulfillment_info - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types to clear in - * SetInventoryRequest.inventory.fulfillment_info - * * Checks that only the desired fulfillment info types have empty - * SetInventoryRequest.inventory.fulfillment_info.place_ids - * The last update time is recorded for the following inventory fields: - * * Product.price_info google.cloud.retail.v2alpha.Product.price_info - * * Product.availability google.cloud.retail.v2alpha.Product.availability - * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info - * If a full overwrite of inventory information while ignoring timestamps is - * needed, UpdateProduct should be invoked instead. - */ - // const inventory = {} - /** - * Indicates which inventory fields in the provided - * Product google.cloud.retail.v2alpha.Product to update. - * At least one field must be provided. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const setMask = {} - /** - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - */ - // const setTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product with - * name Product.name google.cloud.retail.v2alpha.Product.name is not found, - * the inventory update will still be processed and retained for at most 1 day - * until the Product google.cloud.retail.v2alpha.Product is created. If set - * to false, a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callSetInventory() { - // Construct request - const request = { - inventory, - }; - - // Run request - const [operation] = await retailClient.setInventory(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInventory(); - // [END retail_v2alpha_generated_ProductService_SetInventory_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js deleted file mode 100644 index db9b00e4..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START retail_v2alpha_generated_ProductService_UpdateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The product to update/create. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2alpha.Product to update does not - * exist and - * allow_missing google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing - * is not set, a NOT_FOUND error is returned. - */ - // const product = {} - /** - * Indicates which fields in the provided - * Product google.cloud.retail.v2alpha.Product to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, a new Product google.cloud.retail.v2alpha.Product will be - * created. In this situation, `update_mask` is ignored. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await retailClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END retail_v2alpha_generated_ProductService_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js deleted file mode 100644 index 9c4c8b0d..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, visitorId) { - // [START retail_v2alpha_generated_SearchService_Search_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - */ - // const placement = 'abc123' - /** - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - */ - // const branch = 'abc123' - /** - * Raw search query. - */ - // const query = 'abc123' - /** - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * This should be the same identifier as - * UserEvent.visitor_id google.cloud.retail.v2alpha.UserEvent.visitor_id. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * User information. - */ - // const userInfo = {} - /** - * Maximum number of Product google.cloud.retail.v2alpha.Product s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 120. Values above 120 will be coerced to 120. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * SearchResponse.next_page_token google.cloud.retail.v2alpha.SearchResponse.next_page_token, - * received from a previous - * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * Product google.cloud.retail.v2alpha.Product s deemed by the API as - * relevant) in search results. This field is only considered if - * page_token google.cloud.retail.v2alpha.SearchRequest.page_token is - * unset. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const offset = 1234 - /** - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const filter = 'abc123' - /** - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * SearchRequest.canonical_filter google.cloud.retail.v2alpha.SearchRequest.canonical_filter - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * See - * SearchRequest.filter google.cloud.retail.v2alpha.SearchRequest.filter - * for more details about filter syntax. - */ - // const canonicalFilter = 'abc123' - /** - * The order in which products are returned. Products can be ordered by - * a field in an Product google.cloud.retail.v2alpha.Product object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#order). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const orderBy = 'abc123' - /** - * Facet specifications for faceted search. If empty, no facets are returned. - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - */ - // const facetSpecs = 1234 - /** - * Boost specification to boost certain products. See more details at this - * user guide (https://cloud.google.com/retail/docs/boosting). - * Notice that if both - * ServingConfig.boost_control_ids google.cloud.retail.v2alpha.ServingConfig.boost_control_ids - * and SearchRequest.boost_spec are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - */ - // const boostSpec = {} - /** - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this user - * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). - */ - // const queryExpansionSpec = {} - /** - * The relevance threshold of the search results. - * Defaults to - * RelevanceThreshold.HIGH google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH, - * which means only the most relevant results are shown, and the least number - * of results are returned. See more details at this user - * guide (https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - */ - // const relevanceThreshold = {} - /** - * The keys to fetch and rollup the matching - * variant google.cloud.retail.v2alpha.Product.Type.VARIANT - * Product google.cloud.retail.v2alpha.Product s attributes, - * FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo or - * LocalInventory google.cloud.retail.v2alpha.LocalInventory s attributes. - * The attributes from all the matching - * variant google.cloud.retail.v2alpha.Product.Type.VARIANT - * Product google.cloud.retail.v2alpha.Product s or - * LocalInventory google.cloud.retail.v2alpha.LocalInventory s are merged - * and de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * For FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * Supported keys are: - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * Product.inventories.attributes map. - * * attributes.key, where key is any key in the - * Product.attributes google.cloud.retail.v2alpha.Product.attributes map. - * * pickupInStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "pickup-in-store". - * * shipToStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-1". - * * customFulfillment2.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-2". - * * customFulfillment3.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-3". - * * customFulfillment4.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-4". - * * customFulfillment5.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-5". - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - */ - // const variantRollupKeys = 'abc123' - /** - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * UserEvent.page_categories google.cloud.retail.v2alpha.UserEvent.page_categories; - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : "Sales > 2017 Black Friday Deals". - */ - // const pageCategories = 'abc123' - /** - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - */ - // const searchMode = {} - /** - * The specification for personalization. - */ - // const personalizationSpec = {} - - // Imports the Retail library - const {SearchServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new SearchServiceClient(); - - async function callSearch() { - // Construct request - const request = { - placement, - visitorId, - }; - - // Run request - const iterable = await retailClient.searchAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearch(); - // [END retail_v2alpha_generated_SearchService_Search_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js deleted file mode 100644 index 5145a2cb..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig, controlId) { - // [START retail_v2alpha_generated_ServingConfigService_AddControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const servingConfig = 'abc123' - /** - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config - if id is not found a NOT_FOUND error is returned. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callAddControl() { - // Construct request - const request = { - servingConfig, - controlId, - }; - - // Run request - const response = await retailClient.addControl(request); - console.log(response); - } - - callAddControl(); - // [END retail_v2alpha_generated_ServingConfigService_AddControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js deleted file mode 100644 index 5a4982b7..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.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, servingConfig, servingConfigId) { - // [START retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of parent. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Required. The ServingConfig to create. - */ - // const servingConfig = {} - /** - * Required. The ID to use for the ServingConfig, which will become the final - * component of the ServingConfig's resource name. - * This value should be 4-63 characters, and valid characters - * are /[a-z][0-9]-_/. - */ - // const servingConfigId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callCreateServingConfig() { - // Construct request - const request = { - parent, - servingConfig, - servingConfigId, - }; - - // Run request - const response = await retailClient.createServingConfig(request); - console.log(response); - } - - callCreateServingConfig(); - // [END retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js deleted file mode 100644 index 4ca230b4..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the ServingConfig to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callDeleteServingConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteServingConfig(request); - console.log(response); - } - - callDeleteServingConfig(); - // [END retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js deleted file mode 100644 index b88b3af3..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the ServingConfig to get. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callGetServingConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getServingConfig(request); - console.log(response); - } - - callGetServingConfig(); - // [END retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js deleted file mode 100644 index b79bfca1..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.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 retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callListServingConfigs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listServingConfigsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServingConfigs(); - // [END retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js deleted file mode 100644 index c1ea7176..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig, controlId) { - // [START retail_v2alpha_generated_ServingConfigService_RemoveControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const servingConfig = 'abc123' - /** - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callRemoveControl() { - // Construct request - const request = { - servingConfig, - controlId, - }; - - // Run request - const response = await retailClient.removeControl(request); - console.log(response); - } - - callRemoveControl(); - // [END retail_v2alpha_generated_ServingConfigService_RemoveControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js deleted file mode 100644 index 7f236fba..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig) { - // [START retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ServingConfig to update. - */ - // const servingConfig = {} - /** - * Indicates which fields in the provided - * ServingConfig google.cloud.retail.v2alpha.ServingConfig to update. The - * following are NOT supported: - * * ServingConfig.name google.cloud.retail.v2alpha.ServingConfig.name - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callUpdateServingConfig() { - // Construct request - const request = { - servingConfig, - }; - - // Run request - const response = await retailClient.updateServingConfig(request); - console.log(response); - } - - callUpdateServingConfig(); - // [END retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json b/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json deleted file mode 100644 index 1072ee94..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json +++ /dev/null @@ -1,2187 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-retail", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.retail.v2alpha", - "version": "v2alpha" - } - ] - }, - "snippets": [ - { - "regionTag": "retail_v2alpha_generated_CatalogService_ListCatalogs_async", - "title": "CatalogService listCatalogs Sample", - "origin": "API_DEFINITION", - "description": " Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated with the project.", - "canonical": true, - "file": "catalog_service.list_catalogs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ListCatalogsResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCatalog_async", - "title": "CatalogService updateCatalog Sample", - "origin": "API_DEFINITION", - "description": " Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s.", - "canonical": true, - "file": "catalog_service.update_catalog.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": ".google.cloud.retail.v2alpha.Catalog" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Catalog", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_SetDefaultBranch_async", - "title": "CatalogService setDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", - "canonical": true, - "file": "catalog_service.set_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "branch_id", - "type": "TYPE_STRING" - }, - { - "name": "note", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_GetDefaultBranch_async", - "title": "CatalogService getDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] method under a specified parent catalog.", - "canonical": true, - "file": "catalog_service.get_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.GetDefaultBranchResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_GetCompletionConfig_async", - "title": "CatalogService getCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig].", - "canonical": true, - "file": "catalog_service.get_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async", - "title": "CatalogService updateCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s.", - "canonical": true, - "file": "catalog_service.update_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", - "async": true, - "parameters": [ - { - "name": "completion_config", - "type": ".google.cloud.retail.v2alpha.CompletionConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_GetAttributesConfig_async", - "title": "CatalogService getAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig].", - "canonical": true, - "file": "catalog_service.get_attributes_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async", - "title": "CatalogService updateAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", - "canonical": true, - "file": "catalog_service.update_attributes_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": ".google.cloud.retail.v2alpha.AttributesConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async", - "title": "CatalogService addCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", - "canonical": true, - "file": "catalog_service.add_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2alpha.CatalogAttribute" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async", - "title": "CatalogService removeCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "catalog_service.remove_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "key", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async", - "title": "CatalogService replaceCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "catalog_service.replace_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2alpha.CatalogAttribute" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CompletionService_CompleteQuery_async", - "title": "CatalogService completeQuery Sample", - "origin": "API_DEFINITION", - "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 109, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "language_codes", - "type": "TYPE_STRING[]" - }, - { - "name": "device_type", - "type": "TYPE_STRING" - }, - { - "name": "dataset", - "type": "TYPE_STRING" - }, - { - "name": "max_suggestions", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.retail.v2alpha.CompleteQueryResponse", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" - }, - "method": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2alpha.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CompletionService_ImportCompletionData_async", - "title": "CatalogService importCompletionData Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.import_completion_data.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2alpha.CompletionDataInputConfig" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" - }, - "method": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2alpha.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_CreateControl_async", - "title": "CatalogService createControl Sample", - "origin": "API_DEFINITION", - "description": " Creates a Control. If the [Control][google.cloud.retail.v2alpha.Control] to create already exists, an ALREADY_EXISTS error is returned.", - "canonical": true, - "file": "control_service.create_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "control", - "type": ".google.cloud.retail.v2alpha.Control" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_DeleteControl_async", - "title": "CatalogService deleteControl Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Control. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.delete_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_UpdateControl_async", - "title": "CatalogService updateControl Sample", - "origin": "API_DEFINITION", - "description": " Updates a Control. [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.update_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", - "async": true, - "parameters": [ - { - "name": "control", - "type": ".google.cloud.retail.v2alpha.Control" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_GetControl_async", - "title": "CatalogService getControl Sample", - "origin": "API_DEFINITION", - "description": " Gets a Control.", - "canonical": true, - "file": "control_service.get_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_ListControls_async", - "title": "CatalogService listControls Sample", - "origin": "API_DEFINITION", - "description": " Lists all Controls linked to this catalog.", - "canonical": true, - "file": "control_service.list_controls.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ListControlsResponse", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_PredictionService_Predict_async", - "title": "CatalogService predict Sample", - "origin": "API_DEFINITION", - "description": " Makes a recommendation prediction.", - "canonical": true, - "file": "prediction_service.predict.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 153, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2alpha.UserEvent" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "params", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.retail.v2alpha.PredictResponse", - "client": { - "shortName": "PredictionServiceClient", - "fullName": "google.cloud.retail.v2alpha.PredictionServiceClient" - }, - "method": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", - "service": { - "shortName": "PredictionService", - "fullName": "google.cloud.retail.v2alpha.PredictionService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_CreateProduct_async", - "title": "CatalogService createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Product][google.cloud.retail.v2alpha.Product].", - "canonical": true, - "file": "product_service.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.retail.v2alpha.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_GetProduct_async", - "title": "CatalogService getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Product][google.cloud.retail.v2alpha.Product].", - "canonical": true, - "file": "product_service.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_ListProducts_async", - "title": "CatalogService listProducts Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Product][google.cloud.retail.v2alpha.Product]s.", - "canonical": true, - "file": "product_service.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 133, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "read_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "require_total_size", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ListProductsResponse", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_UpdateProduct_async", - "title": "CatalogService updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Product][google.cloud.retail.v2alpha.Product].", - "canonical": true, - "file": "product_service.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.retail.v2alpha.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_DeleteProduct_async", - "title": "CatalogService deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Product][google.cloud.retail.v2alpha.Product].", - "canonical": true, - "file": "product_service.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_PurgeProducts_async", - "title": "CatalogService purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes all selected [Product][google.cloud.retail.v2alpha.Product]s under a branch. This process is asynchronous. If the request is valid, the removal will be enqueued and processed offline. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. Before the operation completes, some [Product][google.cloud.retail.v2alpha.Product]s may still be returned by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. To get a sample of [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] to false.", - "canonical": true, - "file": "product_service.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 93, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_ImportProducts_async", - "title": "CatalogService importProducts Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated.", - "canonical": true, - "file": "product_service.import_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 85, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2alpha.ProductInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "reconciliation_mode", - "type": ".google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_SetInventory_async", - "title": "CatalogService setInventory Sample", - "origin": "API_DEFINITION", - "description": " Updates inventory information for a [Product][google.cloud.retail.v2alpha.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.set_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 116, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", - "async": true, - "parameters": [ - { - "name": "inventory", - "type": ".google.cloud.retail.v2alpha.Product" - }, - { - "name": "set_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "set_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async", - "title": "CatalogService addFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 107, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async", - "title": "CatalogService removeFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 103, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_AddLocalInventories_async", - "title": "CatalogService addLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Updates local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 92, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "local_inventories", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "add_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_RemoveLocalInventories_async", - "title": "CatalogService removeLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Remove local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_SearchService_Search_async", - "title": "CatalogService search Sample", - "origin": "API_DEFINITION", - "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 273, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2alpha.SearchService.Search", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "branch", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "user_info", - "type": ".google.cloud.retail.v2alpha.UserInfo" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "offset", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "canonical_filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "facet_specs", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "dynamic_facet_spec", - "type": ".google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec" - }, - { - "name": "boost_spec", - "type": ".google.cloud.retail.v2alpha.SearchRequest.BoostSpec" - }, - { - "name": "query_expansion_spec", - "type": ".google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec" - }, - { - "name": "relevance_threshold", - "type": ".google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold" - }, - { - "name": "variant_rollup_keys", - "type": "TYPE_STRING[]" - }, - { - "name": "page_categories", - "type": "TYPE_STRING[]" - }, - { - "name": "search_mode", - "type": ".google.cloud.retail.v2alpha.SearchRequest.SearchMode" - }, - { - "name": "personalization_spec", - "type": ".google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec" - } - ], - "resultType": ".google.cloud.retail.v2alpha.SearchResponse", - "client": { - "shortName": "SearchServiceClient", - "fullName": "google.cloud.retail.v2alpha.SearchServiceClient" - }, - "method": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2alpha.SearchService.Search", - "service": { - "shortName": "SearchService", - "fullName": "google.cloud.retail.v2alpha.SearchService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async", - "title": "CatalogService createServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a FAILED_PRECONDITION error is returned.", - "canonical": true, - "file": "serving_config_service.create_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "serving_config", - "type": ".google.cloud.retail.v2alpha.ServingConfig" - }, - { - "name": "serving_config_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async", - "title": "CatalogService deleteServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", - "canonical": true, - "file": "serving_config_service.delete_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async", - "title": "CatalogService updateServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates a ServingConfig.", - "canonical": true, - "file": "serving_config_service.update_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": ".google.cloud.retail.v2alpha.ServingConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_GetServingConfig_async", - "title": "CatalogService getServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", - "canonical": true, - "file": "serving_config_service.get_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async", - "title": "CatalogService listServingConfigs Sample", - "origin": "API_DEFINITION", - "description": " Lists all ServingConfigs linked to this catalog.", - "canonical": true, - "file": "serving_config_service.list_serving_configs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ListServingConfigsResponse", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_AddControl_async", - "title": "CatalogService addControl Sample", - "origin": "API_DEFINITION", - "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", - "canonical": true, - "file": "serving_config_service.add_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_RemoveControl_async", - "title": "CatalogService removeControl Sample", - "origin": "API_DEFINITION", - "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", - "canonical": true, - "file": "serving_config_service.remove_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_WriteUserEvent_async", - "title": "CatalogService writeUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event.", - "canonical": true, - "file": "user_event_service.write_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2alpha.UserEvent" - } - ], - "resultType": ".google.cloud.retail.v2alpha.UserEvent", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_CollectUserEvent_async", - "title": "CatalogService collectUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", - "canonical": true, - "file": "user_event_service.collect_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.api.HttpBody", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_PurgeUserEvents_async", - "title": "CatalogService purgeUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", - "canonical": true, - "file": "user_event_service.purge_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 83, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_ImportUserEvents_async", - "title": "CatalogService importUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", - "canonical": true, - "file": "user_event_service.import_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2alpha.UserEventInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_RejoinUserEvents_async", - "title": "CatalogService rejoinUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", - "canonical": true, - "file": "user_event_service.rejoin_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event_rejoin_scope", - "type": ".google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js deleted file mode 100644 index 2c259bbf..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2alpha_generated_UserEventService_CollectUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - */ - // const userEvent = 'abc123' - /** - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - */ - // const uri = 'abc123' - /** - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - */ - // const ets = 1234 - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callCollectUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.collectUserEvent(request); - console.log(response); - } - - callCollectUserEvent(); - // [END retail_v2alpha_generated_UserEventService_CollectUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js deleted file mode 100644 index 733e1b2f..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2alpha_generated_UserEventService_ImportUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. `projects/1234/locations/global/catalogs/default_catalog` - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - */ - // const errorsConfig = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callImportUserEvents() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportUserEvents(); - // [END retail_v2alpha_generated_UserEventService_ImportUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js deleted file mode 100644 index 9d1d604c..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, filter) { - // [START retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - */ - // const parent = 'abc123' - /** - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * * `eventType`: Double quoted - * UserEvent.event_type google.cloud.retail.v2alpha.UserEvent.event_type - * string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * Examples: - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * The filtering fields are assumed to have an implicit AND. - */ - // const filter = 'abc123' - /** - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - */ - // const force = true - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callPurgeUserEvents() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await retailClient.purgeUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeUserEvents(); - // [END retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js deleted file mode 100644 index e72b2378..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - */ - // const userEventRejoinScope = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callRejoinUserEvents() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await retailClient.rejoinUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRejoinUserEvents(); - // [END retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js deleted file mode 100644 index 8742b980..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2alpha_generated_UserEventService_WriteUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callWriteUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.writeUserEvent(request); - console.log(response); - } - - callWriteUserEvent(); - // [END retail_v2alpha_generated_UserEventService_WriteUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/src/index.ts b/owl-bot-staging/v2alpha/src/index.ts deleted file mode 100644 index ebdb9c41..00000000 --- a/owl-bot-staging/v2alpha/src/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 v2alpha from './v2alpha'; -const CatalogServiceClient = v2alpha.CatalogServiceClient; -type CatalogServiceClient = v2alpha.CatalogServiceClient; -const CompletionServiceClient = v2alpha.CompletionServiceClient; -type CompletionServiceClient = v2alpha.CompletionServiceClient; -const ControlServiceClient = v2alpha.ControlServiceClient; -type ControlServiceClient = v2alpha.ControlServiceClient; -const PredictionServiceClient = v2alpha.PredictionServiceClient; -type PredictionServiceClient = v2alpha.PredictionServiceClient; -const ProductServiceClient = v2alpha.ProductServiceClient; -type ProductServiceClient = v2alpha.ProductServiceClient; -const SearchServiceClient = v2alpha.SearchServiceClient; -type SearchServiceClient = v2alpha.SearchServiceClient; -const ServingConfigServiceClient = v2alpha.ServingConfigServiceClient; -type ServingConfigServiceClient = v2alpha.ServingConfigServiceClient; -const UserEventServiceClient = v2alpha.UserEventServiceClient; -type UserEventServiceClient = v2alpha.UserEventServiceClient; -export {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -export default {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts deleted file mode 100644 index c1af21ae..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts +++ /dev/null @@ -1,1865 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/catalog_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './catalog_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for managing catalog configuration. - * @class - * @memberof v2alpha - */ -export class CatalogServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - catalogServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CatalogServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CatalogServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listCatalogs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.CatalogService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.catalogServiceStub) { - return this.catalogServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.CatalogService. - this.catalogServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.CatalogService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.CatalogService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const catalogServiceStubMethods = - ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch', 'getCompletionConfig', 'updateCompletionConfig', 'getAttributesConfig', 'updateAttributesConfig', 'addCatalogAttribute', 'removeCatalogAttribute', 'replaceCatalogAttribute']; - for (const methodName of catalogServiceStubMethods) { - const callPromise = this.catalogServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.catalogServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Updates the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.Catalog} request.catalog - * Required. The {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2alpha.Catalog|Catalog}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update does not - * exist, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.update_catalog.js - * region_tag:retail_v2alpha_generated_CatalogService_UpdateCatalog_async - */ - updateCatalog( - request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|undefined, {}|undefined - ]>; - updateCatalog( - request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog.name': request.catalog!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCatalog(request, options, callback); - } -/** - * Set a specified branch id as default branch. API methods such as - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search}, - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct}, - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * will treat requests using "default_branch" to the actual branch id set as - * default. - * - * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as - * default, setting - * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent - * to setting - * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/1`. - * - * Using multiple branches can be useful when developers would like - * to have a staging branch to test and verify for future usage. When it - * becomes ready, developers switch on the staging branch using this API while - * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` - * as {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} - * to route the traffic to this staging branch. - * - * CAUTION: If you have live predict/search traffic, switching the default - * branch could potentially cause outages if the ID space of the new branch is - * very different from the old one. - * - * More specifically: - * - * * PredictionService will only return product IDs from branch {newBranch}. - * * SearchService will only return product IDs from branch {newBranch} - * (if branch is not explicitly set). - * * UserEventService will only join events with products from branch - * {newBranch}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.branchId - * The final component of the resource name of a branch. - * - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * - * If there are no sufficient active products in the targeted branch and - * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.force|force} is not - * set, a FAILED_PRECONDITION error is returned. - * @param {string} request.note - * Some note on this request, this can be retrieved by - * {@link google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} - * before next valid default branch set occurs. - * - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {boolean} request.force - * If set to true, it permits switching to a branch with - * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id|branch_id} - * even if it has no sufficient active products. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.set_default_branch.js - * region_tag:retail_v2alpha_generated_CatalogService_SetDefaultBranch_async - */ - setDefaultBranch( - request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|undefined, {}|undefined - ]>; - setDefaultBranch( - request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.setDefaultBranch(request, options, callback); - } -/** - * Get which branch is currently default branch set by - * {@link google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} - * method under a specified parent catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2alpha.GetDefaultBranchResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.get_default_branch.js - * region_tag:retail_v2alpha_generated_CatalogService_GetDefaultBranch_async - */ - getDefaultBranch( - request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|undefined, {}|undefined - ]>; - getDefaultBranch( - request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.getDefaultBranch(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full CompletionConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.get_completion_config.js - * region_tag:retail_v2alpha_generated_CatalogService_GetCompletionConfig_async - */ - getCompletionConfig( - request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|undefined, {}|undefined - ]>; - getCompletionConfig( - request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getCompletionConfig(request, options, callback); - } -/** - * Updates the - * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.CompletionConfig} request.completionConfig - * Required. The - * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}, then a - * PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to - * update does not exist, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. - * The following are the only supported fields: - * - * * {@link google.cloud.retail.v2alpha.CompletionConfig.matching_order|CompletionConfig.matching_order} - * * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} - * * {@link google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} - * * {@link google.cloud.retail.v2alpha.CompletionConfig.auto_learning|CompletionConfig.auto_learning} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.update_completion_config.js - * region_tag:retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async - */ - updateCompletionConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|undefined, {}|undefined - ]>; - updateCompletionConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'completion_config.name': request.completionConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCompletionConfig(request, options, callback); - } -/** - * Gets an {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.get_attributes_config.js - * region_tag:retail_v2alpha_generated_CatalogService_GetAttributesConfig_async - */ - getAttributesConfig( - request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|undefined, {}|undefined - ]>; - getAttributesConfig( - request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getAttributesConfig(request, options, callback); - } -/** - * Updates the - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * The catalog attributes in the request will be updated in the catalog, or - * inserted if they do not exist. Existing catalog attributes not included in - * the request will remain unchanged. Attributes that are assigned to - * products, but do not exist at the catalog level, are always included in the - * response. The product attribute is assigned default values for missing - * catalog attribute fields, e.g., searchable and dynamic facetable options. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.AttributesConfig} request.attributesConfig - * Required. The - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. - * The following is the only supported field: - * - * * {@link google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.update_attributes_config.js - * region_tag:retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async - */ - updateAttributesConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|undefined, {}|undefined - ]>; - updateAttributesConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config.name': request.attributesConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateAttributesConfig(request, options, callback); - } -/** - * Adds the specified - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to the - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to - * add already exists, an ALREADY_EXISTS error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute - * Required. The - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to add. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.add_catalog_attribute.js - * region_tag:retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async - */ - addCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|undefined, {}|undefined - ]>; - addCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.addCatalogAttribute(request, options, callback); - } -/** - * Removes the specified - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} from the - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to - * remove does not exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {string} request.key - * Required. The attribute name key of the - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to remove. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js - * region_tag:retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async - */ - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|undefined, {}|undefined - ]>; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.removeCatalogAttribute(request, options, callback); - } -/** - * Replaces the specified - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} in the - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} by - * updating the catalog attribute with the same - * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key}. - * - * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to - * replace does not exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute - * Required. The updated - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to update. - * The following are NOT supported: - * - * * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js - * region_tag:retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async - */ - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|undefined, {}|undefined - ]>; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.replaceCatalogAttribute(request, options, callback); - } - - /** - * Lists all the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s associated - * with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to - * return. If unspecified, defaults to 50. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogs( - request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICatalog[], - protos.google.cloud.retail.v2alpha.IListCatalogsRequest|null, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse - ]>; - listCatalogs( - request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.ICatalog>): void; - listCatalogs( - request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.ICatalog>): void; - listCatalogs( - request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.ICatalog>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.ICatalog>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICatalog[], - protos.google.cloud.retail.v2alpha.IListCatalogsRequest|null, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listCatalogs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to - * return. If unspecified, defaults to 50. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2alpha.Catalog} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogsStream( - request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.createStream( - this.innerApiCalls.listCatalogs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listCatalogs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to - * return. If unspecified, defaults to 50. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.list_catalogs.js - * region_tag:retail_v2alpha_generated_CatalogService_ListCatalogs_async - */ - listCatalogsAsync( - request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.asyncIterate( - this.innerApiCalls['listCatalogs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.catalogServiceStub && !this._terminated) { - return this.catalogServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json deleted file mode 100644 index 08407daa..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.CatalogService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListCatalogs": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCatalog": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "SetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetCompletionConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCompletionConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetAttributesConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateAttributesConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "AddCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "RemoveCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ReplaceCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts deleted file mode 100644 index 36be33c4..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts +++ /dev/null @@ -1,936 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/completion_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './completion_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Auto-completion service for retail. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2alpha - */ -export class CompletionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - completionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CompletionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CompletionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importCompletionDataResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportCompletionDataResponse') as gax.protobuf.Type; - const importCompletionDataMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importCompletionData: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importCompletionDataResponse.decode.bind(importCompletionDataResponse), - importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.CompletionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.completionServiceStub) { - return this.completionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.CompletionService. - this.completionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.CompletionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.CompletionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const completionServiceStubMethods = - ['completeQuery', 'importCompletionData']; - for (const methodName of completionServiceStubMethods) { - const callPromise = this.completionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.completionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Completes the specified prefix with keyword suggestions. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Required. Catalog for which the completion is performed. - * - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.query - * Required. The query used to generate suggestions. - * - * The maximum number of allowed characters is 255. - * @param {string} request.visitorId - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {string[]} request.languageCodes - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see [Tags for - * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - * @param {string} request.deviceType - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * - * Supported formats: - * - * * `UNKNOWN_DEVICE_TYPE` - * - * * `DESKTOP` - * - * * `MOBILE` - * - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - * @param {string} request.dataset - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * {@link google.cloud.retail.v2alpha.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * - * Current supported values: - * - * * user-data - * - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - * @param {number} request.maxSuggestions - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value - * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. - * - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2alpha.CompleteQueryResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/completion_service.complete_query.js - * region_tag:retail_v2alpha_generated_CompletionService_CompleteQuery_async - */ - completeQuery( - request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|undefined, {}|undefined - ]>; - completeQuery( - request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.completeQuery(request, options, callback); - } - -/** - * Bulk import of processed completion dataset. - * - * Request processing is asynchronous. Partial updating is not supported. - * - * The operation is successfully finished only after the imported suggestions - * are indexed successfully and ready for serving. The process takes hours. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog which the suggestions dataset belongs to. - * - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2alpha.CompletionDataInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js - * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async - */ - importCompletionData( - request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importCompletionData( - request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importCompletionData(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importCompletionData()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js - * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async - */ - async checkImportCompletionDataProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.completionServiceStub && !this._terminated) { - return this.completionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json deleted file mode 100644 index ac2795a5..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.CompletionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CompleteQuery": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ImportCompletionData": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts deleted file mode 100644 index bef33ee7..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts +++ /dev/null @@ -1,1195 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/control_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './control_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for modifying Control. - * @class - * @memberof v2alpha - */ -export class ControlServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - controlServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ControlServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ControlServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listControls: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'controls') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.ControlService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.controlServiceStub) { - return this.controlServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.ControlService. - this.controlServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ControlService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.ControlService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const controlServiceStubMethods = - ['createControl', 'deleteControl', 'updateControl', 'getControl', 'listControls']; - for (const methodName of controlServiceStubMethods) { - const callPromise = this.controlServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.controlServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a Control. - * - * If the {@link google.cloud.retail.v2alpha.Control|Control} to create already - * exists, an ALREADY_EXISTS error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full resource name of parent catalog. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {google.cloud.retail.v2alpha.Control} request.control - * Required. The Control to create. - * @param {string} request.controlId - * Required. The ID to use for the Control, which will become the final - * component of the Control's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link 0-9|a-z}-_/. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.create_control.js - * region_tag:retail_v2alpha_generated_ControlService_CreateControl_async - */ - createControl( - request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|undefined, {}|undefined - ]>; - createControl( - request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createControl(request, options, callback); - } -/** - * Deletes a Control. - * - * If the {@link google.cloud.retail.v2alpha.Control|Control} to delete does not - * exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.delete_control.js - * region_tag:retail_v2alpha_generated_ControlService_DeleteControl_async - */ - deleteControl( - request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|undefined, {}|undefined - ]>; - deleteControl( - request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteControl(request, options, callback); - } -/** - * Updates a Control. - * - * {@link google.cloud.retail.v2alpha.Control|Control} cannot be set to a different - * oneof field, if so an INVALID_ARGUMENT is returned. If the - * {@link google.cloud.retail.v2alpha.Control|Control} to delete does not exist, a - * NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.Control} request.control - * Required. The Control to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.Control|Control} to update. The following are - * NOT supported: - * - * * {@link google.cloud.retail.v2alpha.Control.name|Control.name} - * - * If not set or empty, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.update_control.js - * region_tag:retail_v2alpha_generated_ControlService_UpdateControl_async - */ - updateControl( - request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|undefined, {}|undefined - ]>; - updateControl( - request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'control.name': request.control!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateControl(request, options, callback); - } -/** - * Gets a Control. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.get_control.js - * region_tag:retail_v2alpha_generated_ControlService_GetControl_async - */ - getControl( - request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|undefined, {}|undefined - ]>; - getControl( - request: protos.google.cloud.retail.v2alpha.IGetControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request: protos.google.cloud.retail.v2alpha.IGetControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getControl(request, options, callback); - } - - /** - * Lists all Controls linked to this catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Control]{@link google.cloud.retail.v2alpha.Control}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listControlsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listControls( - request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl[], - protos.google.cloud.retail.v2alpha.IListControlsRequest|null, - protos.google.cloud.retail.v2alpha.IListControlsResponse - ]>; - listControls( - request: protos.google.cloud.retail.v2alpha.IListControlsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListControlsRequest, - protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IControl>): void; - listControls( - request: protos.google.cloud.retail.v2alpha.IListControlsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListControlsRequest, - protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IControl>): void; - listControls( - request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.IListControlsRequest, - protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IControl>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListControlsRequest, - protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IControl>): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl[], - protos.google.cloud.retail.v2alpha.IListControlsRequest|null, - protos.google.cloud.retail.v2alpha.IListControlsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listControls(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Control]{@link google.cloud.retail.v2alpha.Control} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listControlsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listControlsStream( - request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listControls']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listControls.createStream( - this.innerApiCalls.listControls as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listControls`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Control]{@link google.cloud.retail.v2alpha.Control}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.list_controls.js - * region_tag:retail_v2alpha_generated_ControlService_ListControls_async - */ - listControlsAsync( - request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listControls']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listControls.asyncIterate( - this.innerApiCalls['listControls'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.controlServiceStub && !this._terminated) { - return this.controlServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json deleted file mode 100644 index 9a86d786..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.ControlService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListControls": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json b/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json deleted file mode 100644 index aeabbe19..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json +++ /dev/null @@ -1,581 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.retail.v2alpha", - "libraryPackage": "@google-cloud/retail", - "services": { - "CatalogService": { - "clients": { - "grpc": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "GetCompletionConfig": { - "methods": [ - "getCompletionConfig" - ] - }, - "UpdateCompletionConfig": { - "methods": [ - "updateCompletionConfig" - ] - }, - "GetAttributesConfig": { - "methods": [ - "getAttributesConfig" - ] - }, - "UpdateAttributesConfig": { - "methods": [ - "updateAttributesConfig" - ] - }, - "AddCatalogAttribute": { - "methods": [ - "addCatalogAttribute" - ] - }, - "RemoveCatalogAttribute": { - "methods": [ - "removeCatalogAttribute" - ] - }, - "ReplaceCatalogAttribute": { - "methods": [ - "replaceCatalogAttribute" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "GetCompletionConfig": { - "methods": [ - "getCompletionConfig" - ] - }, - "UpdateCompletionConfig": { - "methods": [ - "updateCompletionConfig" - ] - }, - "GetAttributesConfig": { - "methods": [ - "getAttributesConfig" - ] - }, - "UpdateAttributesConfig": { - "methods": [ - "updateAttributesConfig" - ] - }, - "AddCatalogAttribute": { - "methods": [ - "addCatalogAttribute" - ] - }, - "RemoveCatalogAttribute": { - "methods": [ - "removeCatalogAttribute" - ] - }, - "ReplaceCatalogAttribute": { - "methods": [ - "replaceCatalogAttribute" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - } - } - }, - "CompletionService": { - "clients": { - "grpc": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - } - } - }, - "ControlService": { - "clients": { - "grpc": { - "libraryClient": "ControlServiceClient", - "rpcs": { - "CreateControl": { - "methods": [ - "createControl" - ] - }, - "DeleteControl": { - "methods": [ - "deleteControl" - ] - }, - "UpdateControl": { - "methods": [ - "updateControl" - ] - }, - "GetControl": { - "methods": [ - "getControl" - ] - }, - "ListControls": { - "methods": [ - "listControls", - "listControlsStream", - "listControlsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ControlServiceClient", - "rpcs": { - "CreateControl": { - "methods": [ - "createControl" - ] - }, - "DeleteControl": { - "methods": [ - "deleteControl" - ] - }, - "UpdateControl": { - "methods": [ - "updateControl" - ] - }, - "GetControl": { - "methods": [ - "getControl" - ] - }, - "ListControls": { - "methods": [ - "listControls", - "listControlsStream", - "listControlsAsync" - ] - } - } - } - } - }, - "PredictionService": { - "clients": { - "grpc": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - } - } - }, - "ProductService": { - "clients": { - "grpc": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - } - } - }, - "SearchService": { - "clients": { - "grpc": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - } - } - }, - "ServingConfigService": { - "clients": { - "grpc": { - "libraryClient": "ServingConfigServiceClient", - "rpcs": { - "CreateServingConfig": { - "methods": [ - "createServingConfig" - ] - }, - "DeleteServingConfig": { - "methods": [ - "deleteServingConfig" - ] - }, - "UpdateServingConfig": { - "methods": [ - "updateServingConfig" - ] - }, - "GetServingConfig": { - "methods": [ - "getServingConfig" - ] - }, - "AddControl": { - "methods": [ - "addControl" - ] - }, - "RemoveControl": { - "methods": [ - "removeControl" - ] - }, - "ListServingConfigs": { - "methods": [ - "listServingConfigs", - "listServingConfigsStream", - "listServingConfigsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ServingConfigServiceClient", - "rpcs": { - "CreateServingConfig": { - "methods": [ - "createServingConfig" - ] - }, - "DeleteServingConfig": { - "methods": [ - "deleteServingConfig" - ] - }, - "UpdateServingConfig": { - "methods": [ - "updateServingConfig" - ] - }, - "GetServingConfig": { - "methods": [ - "getServingConfig" - ] - }, - "AddControl": { - "methods": [ - "addControl" - ] - }, - "RemoveControl": { - "methods": [ - "removeControl" - ] - }, - "ListServingConfigs": { - "methods": [ - "listServingConfigs", - "listServingConfigsStream", - "listServingConfigsAsync" - ] - } - } - } - } - }, - "UserEventService": { - "clients": { - "grpc": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/index.ts b/owl-bot-staging/v2alpha/src/v2alpha/index.ts deleted file mode 100644 index a7e4f6ba..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {CatalogServiceClient} from './catalog_service_client'; -export {CompletionServiceClient} from './completion_service_client'; -export {ControlServiceClient} from './control_service_client'; -export {PredictionServiceClient} from './prediction_service_client'; -export {ProductServiceClient} from './product_service_client'; -export {SearchServiceClient} from './search_service_client'; -export {ServingConfigServiceClient} from './serving_config_service_client'; -export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts deleted file mode 100644 index 6a5d9153..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts +++ /dev/null @@ -1,837 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/prediction_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './prediction_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for making recommendation prediction. - * @class - * @memberof v2alpha - */ -export class PredictionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - predictionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PredictionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PredictionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.PredictionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.predictionServiceStub) { - return this.predictionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.PredictionService. - this.predictionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.PredictionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.PredictionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const predictionServiceStubMethods = - ['predict']; - for (const methodName of predictionServiceStubMethods) { - const callPromise = this.predictionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.predictionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Makes a recommendation prediction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see [Managing - * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - * @param {number} request.pageSize - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - * @param {string} request.pageToken - * The previous PredictResponse.next_page_token. - * @param {string} request.filter - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * - * Examples: - * - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - * @param {boolean} request.validateOnly - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - * @param {number[]} request.params - * Additional domain specific parameters for the predictions. - * - * Allowed values: - * - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - * @param {number[]} request.labels - * The labels applied to a resource must meet the following requirements: - * - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * - * See [Google Cloud - * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2alpha.PredictResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/prediction_service.predict.js - * region_tag:retail_v2alpha_generated_PredictionService_Predict_async - */ - predict( - request?: protos.google.cloud.retail.v2alpha.IPredictRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|undefined, {}|undefined - ]>; - predict( - request: protos.google.cloud.retail.v2alpha.IPredictRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request: protos.google.cloud.retail.v2alpha.IPredictRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request?: protos.google.cloud.retail.v2alpha.IPredictRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.predict(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.predictionServiceStub && !this._terminated) { - return this.predictionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json deleted file mode 100644 index ed48fe50..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.PredictionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Predict": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts deleted file mode 100644 index 0d593a5e..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts +++ /dev/null @@ -1,2641 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/product_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting {@link google.cloud.retail.v2alpha.Product|Product} - * information of the customer's website. - * @class - * @memberof v2alpha - */ -export class ProductServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ProductServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.PurgeProductsResponse') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.PurgeProductsMetadata') as gax.protobuf.Type; - const importProductsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportProductsResponse') as gax.protobuf.Type; - const importProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; - const setInventoryResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.SetInventoryResponse') as gax.protobuf.Type; - const setInventoryMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.SetInventoryMetadata') as gax.protobuf.Type; - const addFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse') as gax.protobuf.Type; - const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; - const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; - const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; - const addLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.AddLocalInventoriesResponse') as gax.protobuf.Type; - const addLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata') as gax.protobuf.Type; - const removeLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse') as gax.protobuf.Type; - const removeLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)), - importProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductsResponse.decode.bind(importProductsResponse), - importProductsMetadata.decode.bind(importProductsMetadata)), - setInventory: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInventoryResponse.decode.bind(setInventoryResponse), - setInventoryMetadata.decode.bind(setInventoryMetadata)), - addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), - addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), - removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), - removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), - addLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), - addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), - removeLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), - removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.ProductService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.productServiceStub) { - return this.productServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.ProductService. - this.productServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ProductService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.ProductService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const productServiceStubMethods = - ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'purgeProducts', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; - for (const methodName of productServiceStubMethods) { - const callPromise = this.productServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.productServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a {@link google.cloud.retail.v2alpha.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - * @param {google.cloud.retail.v2alpha.Product} request.product - * Required. The {@link google.cloud.retail.v2alpha.Product|Product} to create. - * @param {string} request.productId - * Required. The ID to use for the - * {@link google.cloud.retail.v2alpha.Product|Product}, which will become the final - * component of the {@link google.cloud.retail.v2alpha.Product.name|Product.name}. - * - * If the caller does not have permission to create the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * This field must be unique among all - * {@link google.cloud.retail.v2alpha.Product|Product}s with the same - * {@link google.cloud.retail.v2alpha.CreateProductRequest.parent|parent}. - * Otherwise, an ALREADY_EXISTS error is returned. - * - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.create_product.js - * region_tag:retail_v2alpha_generated_ProductService_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2alpha.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the requested {@link google.cloud.retail.v2alpha.Product|Product} does not - * exist, a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.get_product.js - * region_tag:retail_v2alpha_generated_ProductService_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.retail.v2alpha.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.retail.v2alpha.IGetProductRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Updates a {@link google.cloud.retail.v2alpha.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.Product} request.product - * Required. The product to update/create. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not - * exist and - * {@link google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing|allow_missing} - * is not set, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.Product|Product} to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, a new {@link google.cloud.retail.v2alpha.Product|Product} will be - * created. In this situation, `update_mask` is ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.update_product.js - * region_tag:retail_v2alpha_generated_ProductService_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Deletes a {@link google.cloud.retail.v2alpha.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to delete the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.Product|Product} to delete does not - * exist, a NOT_FOUND error is returned. - * - * The {@link google.cloud.retail.v2alpha.Product|Product} to delete can neither be - * a - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product} member nor a - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product} with more than one - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variants}. Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * All inventory information for the named - * {@link google.cloud.retail.v2alpha.Product|Product} will be deleted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.delete_product.js - * region_tag:retail_v2alpha_generated_ProductService_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } - -/** - * Permanently deletes all selected - * {@link google.cloud.retail.v2alpha.Product|Product}s under a branch. - * - * This process is asynchronous. If the request is valid, the removal will be - * enqueued and processed offline. Depending on the number of - * {@link google.cloud.retail.v2alpha.Product|Product}s, this operation could take - * hours to complete. Before the operation completes, some - * {@link google.cloud.retail.v2alpha.Product|Product}s may still be returned by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * Depending on the number of {@link google.cloud.retail.v2alpha.Product|Product}s, - * this operation could take hours to complete. To get a sample of - * {@link google.cloud.retail.v2alpha.Product|Product}s that would be deleted, set - * {@link google.cloud.retail.v2alpha.PurgeProductsRequest.force|PurgeProductsRequest.force} - * to false. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the branch under which the products are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` - * @param {string} request.filter - * Required. The filter string to specify the products to be deleted with a - * length limit of 5,000 characters. - * - * Empty string filter is not allowed. "*" implies delete all items in a - * branch. - * - * The eligible fields for filtering are: - * - * * `availability`: Double quoted - * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} - * string. - * * `create_time` : in ISO 8601 "zulu" format. - * - * Supported syntax: - * - * * Comparators (">", "<", ">=", "<=", "="). - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" - * * availability = "IN_STOCK" - * - * * Conjunctions ("AND") - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" - * - * * Disjunctions ("OR") - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" - * - * * Can support nested queries. - * Examples: - * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") - * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") - * - * * Filter Limits: - * * Filter should not contain more than 6 conditions. - * * Max nesting depth should not exceed 2 levels. - * - * Examples queries: - * * Delete back order products created before a timestamp. - * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" - * @param {boolean} request.force - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any products. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.purge_products.js - * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.retail.v2alpha.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' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.purge_products.js - * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async - */ - async checkPurgeProductsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeProducts, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Bulk import of multiple {@link google.cloud.retail.v2alpha.Product|Product}s. - * - * Request processing may be synchronous. No partial updating is supported. - * Non-existing items are created. - * - * Note that it is possible for a subset of the - * {@link google.cloud.retail.v2alpha.Product|Product}s to be successfully updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - * @param {string} request.requestId - * Deprecated. This field has no effect. - * @param {google.cloud.retail.v2alpha.ProductInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - * @param {google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode} request.reconciliationMode - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * {@link google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * - * Only supported when - * {@link google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} - * is set to `FULL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.import_products.js - * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async - */ - importProducts( - request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProducts( - request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.import_products.js - * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async - */ - async checkImportProductsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates inventory information for a - * {@link google.cloud.retail.v2alpha.Product|Product} while respecting the last - * update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, updates are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * When inventory is updated with - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct}, - * the specified inventory field value(s) will overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update time for the specified inventory fields will be overwritten to the - * time of the - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} - * or - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} - * request. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2alpha.CreateProductRequest.product|CreateProductRequest.product}, - * then any pre-existing inventory information for this product will be used. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, - * then any existing inventory information will be preserved. - * - * Pre-existing inventory information can only be updated with - * {@link google.cloud.retail.v2alpha.ProductService.SetInventory|SetInventory}, - * {@link google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, - * and - * {@link google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.Product} request.inventory - * Required. The inventory information to update. The allowable fields to - * update are: - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} - * The updated inventory fields must be specified in - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. - * - * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2alpha.Product|Product} named in - * {@link google.cloud.retail.v2alpha.Product.name|Product.name}, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * - * If the {@link google.cloud.retail.v2alpha.Product|Product} to update has - * existing inventory information, the provided inventory information will be - * merged while respecting the last update time for each inventory field, - * using the provided or default value for - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. - * - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} - * - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types to clear in - * {@link |SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} - * - * The last update time is recorded for the following inventory fields: - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} - * - * If a full overwrite of inventory information while ignoring timestamps is - * needed, {@link |UpdateProduct} should be invoked instead. - * @param {google.protobuf.FieldMask} request.setMask - * Indicates which inventory fields in the provided - * {@link google.cloud.retail.v2alpha.Product|Product} to update. - * - * At least one field must be provided. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.setTime - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} with - * name {@link google.cloud.retail.v2alpha.Product.name|Product.name} is not found, - * the inventory update will still be processed and retained for at most 1 day - * until the {@link google.cloud.retail.v2alpha.Product|Product} is created. If set - * to false, a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.set_inventory.js - * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async - */ - setInventory( - request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInventory( - request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'inventory.name': request.inventory!.name || '', - }); - this.initialize(); - return this.innerApiCalls.setInventory(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInventory()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.set_inventory.js - * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async - */ - async checkSetInventoryProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally adds place IDs to - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the added place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}, such - * as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}. - * Duplicate IDs will be automatically ignored. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * If the total number of place IDs exceeds 2000 for this - * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type} after - * adding, then the update will be rejected. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js - * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async - */ - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js - * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async - */ - async checkAddFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally removes place IDs from a - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the removed place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}, - * such as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js - * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async - */ - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js - * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async - */ - async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates local inventory information for a - * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places, while - * respecting the last update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating - * inventory information. If the request is valid, the update will be enqueued - * and processed downstream. As a consequence, when a response is returned, - * updates are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} - * has no effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * @param {number[]} request.localInventories - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - * @param {google.protobuf.FieldMask} request.addMask - * Indicates which inventory fields in the provided list of - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory} to update. The - * field is updated to the provided value. - * - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, the local inventory will still be processed and retained for at - * most 1 day and processed once the - * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js - * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async - */ - addLocalInventories( - request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addLocalInventories( - request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js - * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async - */ - async checkAddLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Remove local inventory information for a - * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places at a - * removal timestamp. - * - * This process is asynchronous. If the request is valid, the removal will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, removals are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} - * has no effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * @param {string[]} request.placeIds - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js - * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async - */ - removeLocalInventories( - request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeLocalInventories( - request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js - * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async - */ - async checkRemoveLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.retail.v2alpha.Product|Product}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to 100. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product} or - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} - * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} - * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} - * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.requireTotalSize - * If true and - * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is - * empty, - * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} - * is set to the total count of matched items irrespective of pagination. - * - * Notice that setting this field to true affects the performance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.retail.v2alpha.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct[], - protos.google.cloud.retail.v2alpha.IListProductsRequest|null, - protos.google.cloud.retail.v2alpha.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.retail.v2alpha.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListProductsRequest, - protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IProduct>): void; - listProducts( - request: protos.google.cloud.retail.v2alpha.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListProductsRequest, - protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IProduct>): void; - listProducts( - request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.IListProductsRequest, - protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListProductsRequest, - protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IProduct>): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct[], - protos.google.cloud.retail.v2alpha.IListProductsRequest|null, - protos.google.cloud.retail.v2alpha.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to 100. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product} or - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} - * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} - * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} - * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.requireTotalSize - * If true and - * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is - * empty, - * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} - * is set to the total count of matched items irrespective of pagination. - * - * Notice that setting this field to true affects the performance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2alpha.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to 100. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product} or - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} - * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} - * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} - * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.requireTotalSize - * If true and - * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is - * empty, - * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} - * is set to the total count of matched items irrespective of pagination. - * - * Notice that setting this field to true affects the performance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.retail.v2alpha.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.list_products.js - * region_tag:retail_v2alpha_generated_ProductService_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.productServiceStub && !this._terminated) { - return this.productServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json deleted file mode 100644 index 416ef1ec..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.ProductService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "GetProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ListProducts": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "UpdateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "DeleteProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "PurgeProducts": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportProducts": { - "timeout_millis": 300000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "SetInventory": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts deleted file mode 100644 index 5e93921a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts +++ /dev/null @@ -1,1537 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/search_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './search_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2alpha - */ -export class SearchServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - searchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SearchServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SearchServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - search: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.SearchService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.searchServiceStub) { - return this.searchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.SearchService. - this.searchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.SearchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.SearchService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const searchServiceStubMethods = - ['search']; - for (const methodName of searchServiceStubMethods) { - const callPromise = this.searchServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.searchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Performs a search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is - * unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See - * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold - * The relevance threshold of the search results. - * - * Defaults to - * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, - * which means only the most relevant results are shown, and the least number - * of results are returned. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, - * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged - * and de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - search( - request?: protos.google.cloud.retail.v2alpha.ISearchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2alpha.ISearchRequest|null, - protos.google.cloud.retail.v2alpha.ISearchResponse - ]>; - search( - request: protos.google.cloud.retail.v2alpha.ISearchRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.ISearchRequest, - protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): void; - search( - request: protos.google.cloud.retail.v2alpha.ISearchRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.ISearchRequest, - protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): void; - search( - request?: protos.google.cloud.retail.v2alpha.ISearchRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.ISearchRequest, - protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.ISearchRequest, - protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): - Promise<[ - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2alpha.ISearchRequest|null, - protos.google.cloud.retail.v2alpha.ISearchResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.search(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is - * unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See - * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold - * The relevance threshold of the search results. - * - * Defaults to - * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, - * which means only the most relevant results are shown, and the least number - * of results are returned. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, - * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged - * and de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - searchStream( - request?: protos.google.cloud.retail.v2alpha.ISearchRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.createStream( - this.innerApiCalls.search as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `search`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is - * unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See - * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold - * The relevance threshold of the search results. - * - * Defaults to - * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, - * which means only the most relevant results are shown, and the least number - * of results are returned. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, - * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged - * and de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/search_service.search.js - * region_tag:retail_v2alpha_generated_SearchService_Search_async - */ - searchAsync( - request?: protos.google.cloud.retail.v2alpha.ISearchRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.asyncIterate( - this.innerApiCalls['search'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.searchServiceStub && !this._terminated) { - return this.searchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json deleted file mode 100644 index 71a5a478..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.SearchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Search": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts deleted file mode 100644 index 1df816d8..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts +++ /dev/null @@ -1,1334 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/serving_config_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './serving_config_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for modifying ServingConfig. - * @class - * @memberof v2alpha - */ -export class ServingConfigServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - servingConfigServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ServingConfigServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ServingConfigServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listServingConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'servingConfigs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.ServingConfigService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.servingConfigServiceStub) { - return this.servingConfigServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.ServingConfigService. - this.servingConfigServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ServingConfigService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.ServingConfigService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const servingConfigServiceStubMethods = - ['createServingConfig', 'deleteServingConfig', 'updateServingConfig', 'getServingConfig', 'listServingConfigs', 'addControl', 'removeControl']; - for (const methodName of servingConfigServiceStubMethods) { - const callPromise = this.servingConfigServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.servingConfigServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a ServingConfig. - * - * A maximum of 100 - * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig}s are allowed in - * a {@link google.cloud.retail.v2alpha.Catalog|Catalog}, otherwise a - * FAILED_PRECONDITION error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full resource name of parent. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig - * Required. The ServingConfig to create. - * @param {string} request.servingConfigId - * Required. The ID to use for the ServingConfig, which will become the final - * component of the ServingConfig's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link 0-9|a-z}-_/. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.create_serving_config.js - * region_tag:retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async - */ - createServingConfig( - request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|undefined, {}|undefined - ]>; - createServingConfig( - request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createServingConfig(request, options, callback); - } -/** - * Deletes a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ServingConfig to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.delete_serving_config.js - * region_tag:retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async - */ - deleteServingConfig( - request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|undefined, {}|undefined - ]>; - deleteServingConfig( - request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteServingConfig(request, options, callback); - } -/** - * Updates a ServingConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig - * Required. The ServingConfig to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig} to update. The - * following are NOT supported: - * - * * {@link google.cloud.retail.v2alpha.ServingConfig.name|ServingConfig.name} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.update_serving_config.js - * region_tag:retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async - */ - updateServingConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|undefined, {}|undefined - ]>; - updateServingConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config.name': request.servingConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateServingConfig(request, options, callback); - } -/** - * Gets a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ServingConfig to get. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.get_serving_config.js - * region_tag:retail_v2alpha_generated_ServingConfigService_GetServingConfig_async - */ - getServingConfig( - request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|undefined, {}|undefined - ]>; - getServingConfig( - request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getServingConfig(request, options, callback); - } -/** - * Enables a Control on the specified ServingConfig. - * The control is added in the last position of the list of controls - * it belongs to (e.g. if it's a facet spec control it will be applied - * in the last position of servingConfig.facetSpecIds) - * Returns a ALREADY_EXISTS error if the control has already been applied. - * Returns a FAILED_PRECONDITION error if the addition could exceed maximum - * number of control allowed for that type of control. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {string} request.controlId - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config - if id is not found a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.add_control.js - * region_tag:retail_v2alpha_generated_ServingConfigService_AddControl_async - */ - addControl( - request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|undefined, {}|undefined - ]>; - addControl( - request: protos.google.cloud.retail.v2alpha.IAddControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request: protos.google.cloud.retail.v2alpha.IAddControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config': request.servingConfig || '', - }); - this.initialize(); - return this.innerApiCalls.addControl(request, options, callback); - } -/** - * Disables a Control on the specified ServingConfig. - * The control is removed from the ServingConfig. - * Returns a NOT_FOUND error if the Control is not enabled for the - * ServingConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {string} request.controlId - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.remove_control.js - * region_tag:retail_v2alpha_generated_ServingConfigService_RemoveControl_async - */ - removeControl( - request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|undefined, {}|undefined - ]>; - removeControl( - request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config': request.servingConfig || '', - }); - this.initialize(); - return this.innerApiCalls.removeControl(request, options, callback); - } - - /** - * Lists all ServingConfigs linked to this catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServingConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listServingConfigs( - request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig[], - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse - ]>; - listServingConfigs( - request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IServingConfig>): void; - listServingConfigs( - request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IServingConfig>): void; - listServingConfigs( - request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IServingConfig>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IServingConfig>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig[], - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listServingConfigs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServingConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listServingConfigsStream( - request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listServingConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServingConfigs.createStream( - this.innerApiCalls.listServingConfigs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServingConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.list_serving_configs.js - * region_tag:retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async - */ - listServingConfigsAsync( - request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listServingConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServingConfigs.asyncIterate( - this.innerApiCalls['listServingConfigs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.servingConfigServiceStub && !this._terminated) { - return this.servingConfigServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json deleted file mode 100644 index 6489c5db..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.ServingConfigService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListServingConfigs": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AddControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts deleted file mode 100644 index bde84f81..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts +++ /dev/null @@ -1,1201 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/user_event_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './user_event_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting end user actions on the customer website. - * @class - * @memberof v2alpha - */ -export class UserEventServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - userEventServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of UserEventServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof UserEventServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const purgeUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.PurgeUserEventsResponse') as gax.protobuf.Type; - const purgeUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.PurgeMetadata') as gax.protobuf.Type; - const importUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportUserEventsResponse') as gax.protobuf.Type; - const importUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; - const rejoinUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RejoinUserEventsResponse') as gax.protobuf.Type; - const rejoinUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RejoinUserEventsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - purgeUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), - purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), - importUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importUserEventsResponse.decode.bind(importUserEventsResponse), - importUserEventsMetadata.decode.bind(importUserEventsMetadata)), - rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), - rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.UserEventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.userEventServiceStub) { - return this.userEventServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.UserEventService. - this.userEventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.UserEventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.UserEventService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const userEventServiceStubMethods = - ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; - for (const methodName of userEventServiceStubMethods) { - const callPromise = this.userEventServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.userEventServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Writes a single user event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent - * Required. User event to write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2alpha.UserEvent}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.write_user_event.js - * region_tag:retail_v2alpha_generated_UserEventService_WriteUserEvent_async - */ - writeUserEvent( - request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|undefined, {}|undefined - ]>; - writeUserEvent( - request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.writeUserEvent(request, options, callback); - } -/** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Retail API JavaScript pixel and Google Tag - * Manager. Users should not call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {string} request.userEvent - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - * @param {string} request.uri - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - * @param {number} request.ets - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.collect_user_event.js - * region_tag:retail_v2alpha_generated_UserEventService_CollectUserEvent_async - */ - collectUserEvent( - request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|undefined, {}|undefined - ]>; - collectUserEvent( - request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.collectUserEvent(request, options, callback); - } - -/** - * Deletes permanently all user events specified by the filter provided. - * Depending on the number of events specified by the filter, this operation - * could take hours or days to complete. To test a filter, use the list - * command first. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - * @param {string} request.filter - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * - * * `eventType`: Double quoted - * {@link google.cloud.retail.v2alpha.UserEvent.event_type|UserEvent.event_type} - * string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * - * Examples: - * - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * - * The filtering fields are assumed to have an implicit AND. - * @param {boolean} request.force - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async - */ - purgeUserEvents( - request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeUserEvents( - request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.purgeUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async - */ - async checkPurgeUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. `projects/1234/locations/global/catalogs/default_catalog` - * @param {google.cloud.retail.v2alpha.UserEventInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async - */ - importUserEvents( - request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importUserEvents( - request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async - */ - async checkImportUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a user event rejoin operation with latest product catalog. Events - * will not be annotated with detailed product information if product is - * missing from the catalog at the time the user event is ingested, and these - * events are stored as unjoined events with a limited usage on training and - * serving. This method can be used to start a join operation on specified - * events with latest version of product catalog. It can also be used to - * correct events joined with the wrong product catalog. A rejoin operation - * can take hours or days to complete. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async - */ - rejoinUserEvents( - request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rejoinUserEvents( - request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.rejoinUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rejoinUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async - */ - async checkRejoinUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.userEventServiceStub && !this._terminated) { - return this.userEventServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json deleted file mode 100644 index 21dfac2e..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.UserEventService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "WriteUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "CollectUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "PurgeUserEvents": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportUserEvents": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "RejoinUserEvents": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 57b7c7be..00000000 --- a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const retail = require('@google-cloud/retail'); - -function main() { - const catalogServiceClient = new retail.CatalogServiceClient(); - const completionServiceClient = new retail.CompletionServiceClient(); - const controlServiceClient = new retail.ControlServiceClient(); - const predictionServiceClient = new retail.PredictionServiceClient(); - const productServiceClient = new retail.ProductServiceClient(); - const searchServiceClient = new retail.SearchServiceClient(); - const servingConfigServiceClient = new retail.ServingConfigServiceClient(); - const userEventServiceClient = new retail.UserEventServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 25eaae42..00000000 --- a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts +++ /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. ** - -import {CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient} from '@google-cloud/retail'; - -// check that the client class type name can be used -function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { - client.close(); -} -function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { - client.close(); -} -function doStuffWithControlServiceClient(client: ControlServiceClient) { - client.close(); -} -function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { - client.close(); -} -function doStuffWithProductServiceClient(client: ProductServiceClient) { - client.close(); -} -function doStuffWithSearchServiceClient(client: SearchServiceClient) { - client.close(); -} -function doStuffWithServingConfigServiceClient(client: ServingConfigServiceClient) { - client.close(); -} -function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const catalogServiceClient = new CatalogServiceClient(); - doStuffWithCatalogServiceClient(catalogServiceClient); - // check that the client instance can be created - const completionServiceClient = new CompletionServiceClient(); - doStuffWithCompletionServiceClient(completionServiceClient); - // check that the client instance can be created - const controlServiceClient = new ControlServiceClient(); - doStuffWithControlServiceClient(controlServiceClient); - // check that the client instance can be created - const predictionServiceClient = new PredictionServiceClient(); - doStuffWithPredictionServiceClient(predictionServiceClient); - // check that the client instance can be created - const productServiceClient = new ProductServiceClient(); - doStuffWithProductServiceClient(productServiceClient); - // check that the client instance can be created - const searchServiceClient = new SearchServiceClient(); - doStuffWithSearchServiceClient(searchServiceClient); - // check that the client instance can be created - const servingConfigServiceClient = new ServingConfigServiceClient(); - doStuffWithServingConfigServiceClient(servingConfigServiceClient); - // check that the client instance can be created - const userEventServiceClient = new UserEventServiceClient(); - doStuffWithUserEventServiceClient(userEventServiceClient); -} - -main(); diff --git a/owl-bot-staging/v2alpha/system-test/install.ts b/owl-bot-staging/v2alpha/system-test/install.ts deleted file mode 100644 index 8ec45222..00000000 --- a/owl-bot-staging/v2alpha/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/v2alpha/test/gapic_catalog_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts deleted file mode 100644 index 017ab407..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts +++ /dev/null @@ -1,1790 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as catalogserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.CatalogServiceClient', () => { - it('has servicePath', () => { - const servicePath = catalogserviceModule.v2alpha.CatalogServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = catalogserviceModule.v2alpha.CatalogServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = catalogserviceModule.v2alpha.CatalogServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - await client.initialize(); - assert(client.catalogServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.catalogServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('updateCatalog', () => { - it('invokes updateCatalog without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); - const [response] = await client.updateCatalog(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCatalog( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICatalog|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCatalog with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCatalog(request), expectedError); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCatalog(request), expectedError); - }); - }); - - describe('setDefaultBranch', () => { - it('invokes setDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.setDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setDefaultBranch( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setDefaultBranch(request), expectedError); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setDefaultBranch(request), expectedError); - }); - }); - - describe('getDefaultBranch', () => { - it('invokes getDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.getDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDefaultBranch( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDefaultBranch(request), expectedError); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDefaultBranch(request), expectedError); - }); - }); - - describe('getCompletionConfig', () => { - it('invokes getCompletionConfig without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCompletionConfig without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); - client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getCompletionConfig with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCompletionConfig(request), expectedError); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCompletionConfig with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getCompletionConfig(request), expectedError); - }); - }); - - describe('updateCompletionConfig', () => { - it('invokes updateCompletionConfig without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCompletionConfig without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); - client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCompletionConfig with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCompletionConfig with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - }); - }); - - describe('getAttributesConfig', () => { - it('invokes getAttributesConfig without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAttributesConfig without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getAttributesConfig with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttributesConfig(request), expectedError); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAttributesConfig with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAttributesConfig(request), expectedError); - }); - }); - - describe('updateAttributesConfig', () => { - it('invokes updateAttributesConfig without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAttributesConfig without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateAttributesConfig with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAttributesConfig with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - }); - }); - - describe('addCatalogAttribute', () => { - it('invokes addCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.addCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - }); - }); - - describe('removeCatalogAttribute', () => { - it('invokes removeCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.removeCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - }); - }); - - describe('replaceCatalogAttribute', () => { - it('invokes replaceCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.replaceCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes replaceCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.replaceCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes replaceCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes replaceCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - }); - }); - - describe('listCatalogs', () => { - it('invokes listCatalogs without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); - const [response] = await client.listCatalogs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogs without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCatalogs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICatalog[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listCatalogs with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCatalogs(request), expectedError); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogsStream without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - ]; - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listCatalogsStream with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - ]; - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; - const iterable = client.listCatalogsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCatalogsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts deleted file mode 100644 index c3aba50c..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts +++ /dev/null @@ -1,703 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as completionserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2alpha.CompletionServiceClient', () => { - it('has servicePath', () => { - const servicePath = completionserviceModule.v2alpha.CompletionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = completionserviceModule.v2alpha.CompletionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = completionserviceModule.v2alpha.CompletionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - await client.initialize(); - assert(client.completionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.completionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery without error using callback', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes completeQuery with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery with closed client', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.completeQuery(request), expectedError); - }); - }); - - describe('importCompletionData', () => { - it('invokes importCompletionData without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); - const [operation] = await client.importCompletionData(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData without error using callback', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importCompletionData( - request, - (err?: Error|null, - result?: LROperation|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.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importCompletionData with call error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importCompletionData(request), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData with LRO error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importCompletionData(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportCompletionDataProgress without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportCompletionDataProgress with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts deleted file mode 100644 index 4f62d30a..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts +++ /dev/null @@ -1,1108 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as controlserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.ControlServiceClient', () => { - it('has servicePath', () => { - const servicePath = controlserviceModule.v2alpha.ControlServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = controlserviceModule.v2alpha.ControlServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = controlserviceModule.v2alpha.ControlServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.controlServiceStub, undefined); - await client.initialize(); - assert(client.controlServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.controlServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.controlServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createControl', () => { - it('invokes createControl without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); - const [response] = await client.createControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createControl without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createControl with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createControl(request), expectedError); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createControl with closed client', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createControl(request), expectedError); - }); - }); - - describe('deleteControl', () => { - it('invokes deleteControl without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); - const [response] = await client.deleteControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteControl without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteControl( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteControl with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteControl(request), expectedError); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteControl with closed client', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteControl(request), expectedError); - }); - }); - - describe('updateControl', () => { - it('invokes updateControl without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); - const [response] = await client.updateControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateControl without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateControl with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateControl(request), expectedError); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateControl with closed client', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateControl(request), expectedError); - }); - }); - - describe('getControl', () => { - it('invokes getControl without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); - const [response] = await client.getControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getControl without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getControl with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getControl(request), expectedError); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getControl with closed client', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getControl(request), expectedError); - }); - }); - - describe('listControls', () => { - it('invokes listControls without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); - const [response] = await client.listControls(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listControls without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listControls( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listControls with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listControls(request), expectedError); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listControlsStream without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - ]; - client.descriptors.page.listControls.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listControlsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Control) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listControls, request)); - assert.strictEqual( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listControlsStream with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listControls.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listControlsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Control) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listControls, request)); - assert.strictEqual( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listControls without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - ]; - client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; - const iterable = client.listControlsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listControls with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listControlsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts deleted file mode 100644 index d449dd3b..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as predictionserviceModule from '../src'; - -import {protobuf} 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('v2alpha.PredictionServiceClient', () => { - it('has servicePath', () => { - const servicePath = predictionserviceModule.v2alpha.PredictionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = predictionserviceModule.v2alpha.PredictionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = predictionserviceModule.v2alpha.PredictionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - await client.initialize(); - assert(client.predictionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.predictionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('predict', () => { - it('invokes predict without error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCall(expectedResponse); - const [response] = await client.predict(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict without error using callback', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.predict( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IPredictResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes predict with error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.predict(request), expectedError); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict with closed client', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); - request.placement = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.predict(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts deleted file mode 100644 index ad57c1e0..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts +++ /dev/null @@ -1,2190 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as productserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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('v2alpha.ProductServiceClient', () => { - it('has servicePath', () => { - const servicePath = productserviceModule.v2alpha.ProductServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productserviceModule.v2alpha.ProductServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productserviceModule.v2alpha.ProductServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productserviceModule.v2alpha.ProductServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - await client.initialize(); - assert(client.productServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeProductsRequest()); - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importProducts', () => { - it('invokes importProducts without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProducts( - request, - (err?: Error|null, - result?: LROperation|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.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProducts with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProducts(request), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductsProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductsProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInventory', () => { - it('invokes setInventory without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInventory(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInventory( - request, - (err?: Error|null, - result?: LROperation|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.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setInventory with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInventory(request), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInventory(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkSetInventoryProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInventoryProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInventoryProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addFulfillmentPlaces', () => { - it('invokes addFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeFulfillmentPlaces', () => { - it('invokes removeFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addLocalInventories', () => { - it('invokes addLocalInventories without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.addLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addLocalInventories with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addLocalInventories(request), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeLocalInventories', () => { - it('invokes removeLocalInventories without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeLocalInventories with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeLocalInventories(request), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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.retail.v2alpha.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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.retail.v2alpha.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts deleted file mode 100644 index 4c28a3a6..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts +++ /dev/null @@ -1,770 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as searchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.SearchServiceClient', () => { - it('has servicePath', () => { - const servicePath = searchserviceModule.v2alpha.SearchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = searchserviceModule.v2alpha.SearchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = searchserviceModule.v2alpha.SearchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - await client.initialize(); - assert(client.searchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.searchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('search', () => { - it('invokes search without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCall(expectedResponse); - const [response] = await client.search(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes search without error using callback', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.search( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes search with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchStream without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes searchStream with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedError = new Error('expected'); - client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = []; - const iterable = client.searchAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts deleted file mode 100644 index f3a80ec9..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts +++ /dev/null @@ -1,1302 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as servingconfigserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.ServingConfigServiceClient', () => { - it('has servicePath', () => { - const servicePath = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servingConfigServiceStub, undefined); - await client.initialize(); - assert(client.servingConfigServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.servingConfigServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servingConfigServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createServingConfig', () => { - it('invokes createServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.createServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createServingConfig(request), expectedError); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createServingConfig(request), expectedError); - }); - }); - - describe('deleteServingConfig', () => { - it('invokes deleteServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.deleteServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServingConfig( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteServingConfig(request), expectedError); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteServingConfig(request), expectedError); - }); - }); - - describe('updateServingConfig', () => { - it('invokes updateServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateServingConfig(request), expectedError); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateServingConfig(request), expectedError); - }); - }); - - describe('getServingConfig', () => { - it('invokes getServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServingConfig(request), expectedError); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getServingConfig(request), expectedError); - }); - }); - - describe('addControl', () => { - it('invokes addControl without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); - const [response] = await client.addControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addControl with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addControl(request), expectedError); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addControl with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); - request.servingConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addControl(request), expectedError); - }); - }); - - describe('removeControl', () => { - it('invokes removeControl without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); - const [response] = await client.removeControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeControl with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeControl(request), expectedError); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeControl with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); - request.servingConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeControl(request), expectedError); - }); - }); - - describe('listServingConfigs', () => { - it('invokes listServingConfigs without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listServingConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServingConfigs without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServingConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServingConfigs(request), expectedError); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServingConfigsStream without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - ]; - client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServingConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listServingConfigsStream with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServingConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServingConfigs without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - ]; - client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = []; - const iterable = client.listServingConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServingConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts deleted file mode 100644 index 4da29c4b..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts +++ /dev/null @@ -1,1088 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as usereventserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2alpha.UserEventServiceClient', () => { - it('has servicePath', () => { - const servicePath = usereventserviceModule.v2alpha.UserEventServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = usereventserviceModule.v2alpha.UserEventServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = usereventserviceModule.v2alpha.UserEventServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - await client.initialize(); - assert(client.userEventServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.userEventServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('writeUserEvent', () => { - it('invokes writeUserEvent without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.writeUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.writeUserEvent( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IUserEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes writeUserEvent with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.writeUserEvent(request), expectedError); - }); - }); - - describe('collectUserEvent', () => { - it('invokes collectUserEvent without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.collectUserEvent( - request, - (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes collectUserEvent with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.collectUserEvent(request), expectedError); - }); - }); - - describe('purgeUserEvents', () => { - it('invokes purgeUserEvents without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeUserEvents with call error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeUserEvents(request), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importUserEvents', () => { - it('invokes importUserEvents without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.importUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importUserEvents with call error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rejoinUserEvents', () => { - it('invokes rejoinUserEvents without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejoinUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejoinUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes rejoinUserEvents with call error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejoinUserEvents(request), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejoinUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRejoinUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRejoinUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/tsconfig.json b/owl-bot-staging/v2alpha/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v2alpha/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/v2alpha/webpack.config.js b/owl-bot-staging/v2alpha/webpack.config.js deleted file mode 100644 index f2c58f25..00000000 --- a/owl-bot-staging/v2alpha/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: 'CatalogService', - filename: './catalog-service.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v2beta/.eslintignore b/owl-bot-staging/v2beta/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v2beta/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v2beta/.eslintrc.json b/owl-bot-staging/v2beta/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v2beta/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v2beta/.gitignore b/owl-bot-staging/v2beta/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v2beta/.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/v2beta/.jsdoc.js b/owl-bot-staging/v2beta/.jsdoc.js deleted file mode 100644 index 19729810..00000000 --- a/owl-bot-staging/v2beta/.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/retail', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v2beta/.mocharc.js b/owl-bot-staging/v2beta/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v2beta/.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/v2beta/.prettierrc.js b/owl-bot-staging/v2beta/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v2beta/.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/v2beta/README.md b/owl-bot-staging/v2beta/README.md deleted file mode 100644 index 822c4573..00000000 --- a/owl-bot-staging/v2beta/README.md +++ /dev/null @@ -1 +0,0 @@ -Retail: Nodejs Client diff --git a/owl-bot-staging/v2beta/linkinator.config.json b/owl-bot-staging/v2beta/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v2beta/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/v2beta/package.json b/owl-bot-staging/v2beta/package.json deleted file mode 100644 index 94071ee3..00000000 --- a/owl-bot-staging/v2beta/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@google-cloud/retail", - "version": "0.1.0", - "description": "Retail client for Node.js", - "repository": "googleapis/nodejs-retail", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google retail", - "retail", - "catalog service", - "completion service", - "control service", - "prediction service", - "product service", - "search service", - "serving config service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto deleted file mode 100644 index e0b844ef..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/import_config.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Configures what level the product should be uploaded with regards to -// how users will be send events and how predictions will be made. -message ProductLevelConfig { - // The type of [Product][google.cloud.retail.v2beta.Product]s allowed to be - // ingested into the catalog. Acceptable values are: - // - // * `primary` (default): You can ingest - // [Product][google.cloud.retail.v2beta.Product]s of all types. When - // ingesting a [Product][google.cloud.retail.v2beta.Product], its type will - // default to - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // if unset. - // * `variant`: You can only ingest - // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s. - // This means - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] - // cannot be empty. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `variant` and - // [merchant_center_product_id_field][google.cloud.retail.v2beta.ProductLevelConfig.merchant_center_product_id_field] - // is `itemGroupId`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string ingestion_product_type = 1; - - // Which field of [Merchant Center - // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be - // imported as [Product.id][google.cloud.retail.v2beta.Product.id]. Acceptable - // values are: - // - // * `offerId` (default): Import `offerId` as the product ID. - // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail - // API will choose one item from the ones with the same `itemGroupId`, and - // use it to represent the item group. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `itemGroupId` and - // [ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] - // is `variant`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string merchant_center_product_id_field = 2; -} - -// Catalog level attribute config for an attribute. For example, if customers -// want to enable/disable facet for a specific attribute. -message CatalogAttribute { - // The type of an attribute. - enum AttributeType { - // The type of the attribute is unknown. - // - // Used when type cannot be derived from attribute that is not - // [in_use][google.cloud.retail.v2beta.CatalogAttribute.in_use]. - UNKNOWN = 0; - - // Textual attribute. - TEXTUAL = 1; - - // Numerical attribute. - NUMERICAL = 2; - } - - // The status of the indexable option of a catalog attribute. - enum IndexableOption { - // Value used when unset. Defaults to - // [INDEXABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. - INDEXABLE_OPTION_UNSPECIFIED = 0; - - // Indexable option enabled for an attribute. - INDEXABLE_ENABLED = 1; - - // Indexable option disabled for an attribute. - INDEXABLE_DISABLED = 2; - } - - // The status of the dynamic facetable option of a catalog attribute. - enum DynamicFacetableOption { - // Value used when unset. Defaults to - // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. - DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; - - // Dynamic facetable option enabled for an attribute. - DYNAMIC_FACETABLE_ENABLED = 1; - - // Dynamic facetable option disabled for an attribute. - DYNAMIC_FACETABLE_DISABLED = 2; - } - - // The status of the searchable option of a catalog attribute. - enum SearchableOption { - // Value used when unset. Defaults to - // [SEARCHABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. - SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Searchable option enabled for an attribute. - SEARCHABLE_ENABLED = 1; - - // Searchable option disabled for an attribute. - SEARCHABLE_DISABLED = 2; - } - - // Required. Attribute name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Output only. Indicates whether this attribute has been used by any - // products. `True` if at least one - // [Product][google.cloud.retail.v2beta.Product] is using this attribute in - // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. - // Otherwise, this field is `False`. - // - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] can be - // pre-loaded by using [AddCatalogAttribute][], [ImportCatalogAttributes][], - // or [UpdateAttributesConfig][] APIs. This field is `False` for pre-loaded - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s. - // - // Only [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that - // are not in use by products can be deleted. - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that are - // in use by products cannot be deleted; however, their configuration - // properties will reset to default values upon removal request. - // - // After catalog changes, it takes about 10 minutes for this field to update. - bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The type of this attribute. This is derived from the attribute - // in [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. - AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values - // are indexed so that it can be filtered, faceted, or boosted in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - IndexableOption indexable_option = 5; - - // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic - // facet. Could only be DYNAMIC_FACETABLE_DISABLED if - // [CatalogAttribute.indexable_option][google.cloud.retail.v2beta.CatalogAttribute.indexable_option] - // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. - DynamicFacetableOption dynamic_facetable_option = 6; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values - // are searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values - // will not be searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], as - // there are no text values associated to numerical attributes. - SearchableOption searchable_option = 7; -} - -// Catalog level attribute config. -message AttributesConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/AttributesConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" - }; - - // Required. Immutable. The fully qualified resource name of the attribute - // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Enable attribute(s) config at catalog level. - // For example, indexable, dynamic_facetable, or searchable for each - // attribute. - // - // The key is catalog attribute's name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - // - // The maximum number of catalog attributes allowed in a request is 1000. - map catalog_attributes = 2; - - // Output only. The - // [AttributeConfigLevel][google.cloud.retail.v2beta.AttributeConfigLevel] - // used for this catalog. - AttributeConfigLevel attribute_config_level = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Catalog level autocomplete config for customers to customize autocomplete -// feature's settings. -message CompletionConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/CompletionConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" - }; - - // Required. Immutable. Fully qualified name - // `projects/*/locations/*/catalogs/*/completionConfig` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Specifies the matching order for autocomplete suggestions, e.g., a query - // consisting of 'sh' with 'out-of-order' specified would suggest "women's - // shoes", whereas a query of 'red s' with 'exact-prefix' specified would - // suggest "red shoes". Currently supported values: - // - // * 'out-of-order' - // * 'exact-prefix' - // - // Default value: 'exact-prefix'. - string matching_order = 2; - - // The maximum number of autocomplete suggestions returned per term. The - // maximum allowed max suggestions is 20. Default value is 20. If left unset - // or set to 0, then will fallback to default value. - int32 max_suggestions = 3; - - // The minimum number of characters needed to be typed in order to get - // suggestions. Default value is 2. If left unset or set to 0, then will - // fallback to default value. - int32 min_prefix_length = 4; - - // If set to true, the auto learning function is enabled. Auto learning uses - // user data to generate suggestions using ML techniques. Default value is - // false. Only after enabling auto learning can users use `cloud-retail` - // data in - // [CompleteQueryRequest][google.cloud.retail.v2beta.CompleteQueryRequest]. - bool auto_learning = 11; - - // Output only. The input config for the import of the source data that - // contains the autocomplete phrases uploaded by the customer. - CompletionDataInputConfig suggestions_input_config = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the LRO corresponding to the latest suggestion terms - // list import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_suggestions_import_operation = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The input config for the import of the source data that - // contains the / autocomplete denylist phrases uploaded by the customer. - CompletionDataInputConfig denylist_input_config = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. LRO corresponding to the latest denylist import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_denylist_import_operation = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The input config for the import of the source data that - // contains the autocomplete allowlist phrases uploaded by the customer. - CompletionDataInputConfig allowlist_input_config = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. LRO corresponding to the latest allowlist import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_allowlist_import_operation = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Represents a link between a Merchant Center account and a branch. -// Once a link is established, products from the linked merchant center account -// will be streamed to the linked branch. -message MerchantCenterLink { - // Required. The linked [Merchant center account - // id](https://developers.google.com/shopping-content/guides/accountstatuses). - // The account must be a standalone account or a sub-account of a MCA. - int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch id (e.g. 0/1/2) within this catalog that products from - // merchant_center_account_id are streamed to. When updating this field, an - // empty value will use the currently configured default branch. However, - // changing the default branch later on won't change the linked branch here. - // - // A single branch id can only have one linked merchant center account id. - string branch_id = 2; - - // String representing the destination to import for, all if left empty. - // List of possible values can be found here. - // [https://support.google.com/merchants/answer/7501026] - // List of allowed string values: - // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory - // _ads", "Free_listings", "Free_local_listings" - // NOTE: The string values are case sensitive. - repeated string destinations = 3; - - // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 - // code. List of values can be found - // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) - // under the `region` tag. If left blank no region filtering will be - // performed. - // - // Example value: `US`. - string region_code = 4; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // ISO 639-1. - // - // This specifies the language of offers in Merchant Center that will be - // accepted. If empty no language filtering will be performed. - // - // Example value: `en`. - string language_code = 5; -} - -// Configures Merchant Center linking. -// Links contained in the config will be used to sync data from a Merchant -// Center account to a Cloud Retail branch. -message MerchantCenterLinkingConfig { - // Links between Merchant Center accounts and branches. - repeated MerchantCenterLink links = 1; -} - -// The catalog configuration. -message Catalog { - option (google.api.resource) = { - type: "retail.googleapis.com/Catalog" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" - }; - - // Required. Immutable. The fully qualified resource name of the catalog. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. Immutable. The catalog display name. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. The product level configuration. - ProductLevelConfig product_level_config = 4 - [(google.api.field_behavior) = REQUIRED]; - - // The Merchant Center linking configuration. - // Once a link is added, the data stream from Merchant Center to Cloud Retail - // will be enabled automatically. The requester must have access to the - // merchant center account in order to make changes to this field. - MerchantCenterLinkingConfig merchant_center_linking_config = 6; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto deleted file mode 100644 index 7e27c916..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto +++ /dev/null @@ -1,478 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/catalog.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for managing catalog configuration. -service CatalogService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated - // with the project. - rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*}/catalogs" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s. - rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { - option (google.api.http) = { - patch: "/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}" - body: "catalog" - }; - option (google.api.method_signature) = "catalog,update_mask"; - } - - // Set a specified branch id as default branch. API methods such as - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] - // will treat requests using "default_branch" to the actual branch id set as - // default. - // - // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as - // default, setting - // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent - // to setting - // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/1`. - // - // Using multiple branches can be useful when developers would like - // to have a staging branch to test and verify for future usage. When it - // becomes ready, developers switch on the staging branch using this API while - // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` - // as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] - // to route the traffic to this staging branch. - // - // CAUTION: If you have live predict/search traffic, switching the default - // branch could potentially cause outages if the ID space of the new branch is - // very different from the old one. - // - // More specifically: - // - // * PredictionService will only return product IDs from branch {newBranch}. - // * SearchService will only return product IDs from branch {newBranch} - // (if branch is not explicitly set). - // * UserEventService will only join events with products from branch - // {newBranch}. - rpc SetDefaultBranch(SetDefaultBranchRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" - body: "*" - }; - option (google.api.method_signature) = "catalog"; - } - - // Get which branch is currently default branch set by - // [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] - // method under a specified parent catalog. - rpc GetDefaultBranch(GetDefaultBranchRequest) - returns (GetDefaultBranchResponse) { - option (google.api.http) = { - get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" - }; - option (google.api.method_signature) = "catalog"; - } - - // Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]. - rpc GetCompletionConfig(GetCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the - // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s. - rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - patch: "/v2beta/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" - body: "completion_config" - }; - option (google.api.method_signature) = "completion_config,update_mask"; - } - - // Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. - rpc GetAttributesConfig(GetAttributesConfigRequest) - returns (AttributesConfig) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. - // - // The catalog attributes in the request will be updated in the catalog, or - // inserted if they do not exist. Existing catalog attributes not included in - // the request will remain unchanged. Attributes that are assigned to - // products, but do not exist at the catalog level, are always included in the - // response. The product attribute is assigned default values for missing - // catalog attribute fields, e.g., searchable and dynamic facetable options. - rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) - returns (AttributesConfig) { - option (google.api.http) = { - patch: "/v2beta/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" - body: "attributes_config" - }; - option (google.api.method_signature) = "attributes_config,update_mask"; - } - - // Adds the specified - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to - // add already exists, an ALREADY_EXISTS error is returned. - rpc AddCatalogAttribute(AddCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" - body: "*" - }; - } - - // Removes the specified - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to - // remove does not exist, a NOT_FOUND error is returned. - rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" - body: "*" - }; - } - - // Replaces the specified - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating - // the catalog attribute with the same - // [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. - // - // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to - // replace does not exist, a NOT_FOUND error is returned. - rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" - body: "*" - }; - } -} - -// Request for -// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] -// method. -message ListCatalogsRequest { - // Required. The account resource name with an associated location. - // - // If the caller does not have permission to list - // [Catalog][google.cloud.retail.v2beta.Catalog]s under this location, - // regardless of whether or not this location exists, a PERMISSION_DENIED - // error is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of [Catalog][google.cloud.retail.v2beta.Catalog]s to return. - // If unspecified, defaults to 50. The maximum allowed value is 1000. Values - // above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 2; - - // A page token - // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token], - // received from a previous - // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; -} - -// Response for -// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] -// method. -message ListCatalogsResponse { - // All the customer's [Catalog][google.cloud.retail.v2beta.Catalog]s. - repeated Catalog catalogs = 1; - - // A token that can be sent as - // [ListCatalogsRequest.page_token][google.cloud.retail.v2beta.ListCatalogsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request for -// [CatalogService.UpdateCatalog][google.cloud.retail.v2beta.CatalogService.UpdateCatalog] -// method. -message UpdateCatalogRequest { - // Required. The [Catalog][google.cloud.retail.v2beta.Catalog] to update. - // - // If the caller does not have permission to update the - // [Catalog][google.cloud.retail.v2beta.Catalog], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // If the [Catalog][google.cloud.retail.v2beta.Catalog] to update does not - // exist, a NOT_FOUND error is returned. - Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Catalog][google.cloud.retail.v2beta.Catalog] to update. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message to set a specified branch as new default_branch. -message SetDefaultBranchRequest { - // Full resource name of the catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // The final component of the resource name of a branch. - // - // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - // error is returned. - // - // If there are no sufficient active products in the targeted branch and - // [force][google.cloud.retail.v2beta.SetDefaultBranchRequest.force] is not - // set, a FAILED_PRECONDITION error is returned. - string branch_id = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Some note on this request, this can be retrieved by - // [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch] - // before next valid default branch set occurs. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string note = 3; - - // If set to true, it permits switching to a branch with - // [branch_id][google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id] - // even if it has no sufficient active products. - bool force = 4; -} - -// Request message to show which branch is currently the default branch. -message GetDefaultBranchRequest { - // The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; -} - -// Response message of -// [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch]. -message GetDefaultBranchResponse { - // Full resource name of the branch id currently set as default branch. - string branch = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // The time when this branch is set to default. - google.protobuf.Timestamp set_time = 2; - - // This corresponds to - // [SetDefaultBranchRequest.note][google.cloud.retail.v2beta.SetDefaultBranchRequest.note] - // field, when this branch was set as default. - string note = 3; -} - -// Request for -// [CatalogService.GetCompletionConfig][google.cloud.retail.v2beta.CatalogService.GetCompletionConfig] -// method. -message GetCompletionConfigRequest { - // Required. Full CompletionConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/CompletionConfig" - } - ]; -} - -// Request for -// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig] -// method. -message UpdateCompletionConfigRequest { - // Required. The - // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. - // - // If the caller does not have permission to update the - // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig], then a - // PERMISSION_DENIED error is returned. - // - // If the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to - // update does not exist, a NOT_FOUND error is returned. - CompletionConfig completion_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. - // The following are the only supported fields: - // - // * [CompletionConfig.matching_order][google.cloud.retail.v2beta.CompletionConfig.matching_order] - // * [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions] - // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2beta.CompletionConfig.min_prefix_length] - // * [CompletionConfig.auto_learning][google.cloud.retail.v2beta.CompletionConfig.auto_learning] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.GetAttributesConfig][google.cloud.retail.v2beta.CatalogService.GetAttributesConfig] -// method. -message GetAttributesConfigRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; -} - -// Request for -// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig] -// method. -message UpdateAttributesConfigRequest { - // Required. The - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. - AttributesConfig attributes_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. - // The following is the only supported field: - // - // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2beta.AttributesConfig.catalog_attributes] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute] -// method. -message AddCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute] -// method. -message RemoveCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The attribute name key of the - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove. - string key = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute] -// method. -message ReplaceCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The updated - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to update. - // The following are NOT supported: - // - // * [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 3; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto deleted file mode 100644 index ada7dd15..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto +++ /dev/null @@ -1,760 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// At which level we offer configuration for attributes. -enum AttributeConfigLevel { - // Value used when unset. Defaults to - // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2beta.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. - ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; - - // At this level, we honor the attribute configurations set in - // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. - PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; - - // At this level, we honor the attribute configurations set in - // [CatalogConfig.attribute_configs][]. - CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; -} - -// The type of solution. -enum SolutionType { - // Default value. - SOLUTION_TYPE_UNSPECIFIED = 0; - - // Used for Recommendations AI. - SOLUTION_TYPE_RECOMMENDATION = 1; - - // Used for Retail Search. - SOLUTION_TYPE_SEARCH = 2; -} - -// The use case of Cloud Retail Search. -enum SearchSolutionUseCase { - // The value when it's unspecified. Defaults to - // [SEARCH][]. - SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; - - // Search use case. Expects the traffic has a non-empty - // [query][google.cloud.retail.v2beta.SearchRequest.query]. - SEARCH_SOLUTION_USE_CASE_SEARCH = 1; - - // Browse use case. Expects the traffic has an empty - // [query][google.cloud.retail.v2beta.SearchRequest.query]. - SEARCH_SOLUTION_USE_CASE_BROWSE = 2; -} - -// Metadata that is used to define a condition that triggers an action. -// A valid condition must specify at least one of 'query_terms' or -// 'products_filter'. If multiple fields are specified, the condition is met if -// all the fields are satisfied e.g. if a set of query terms and product_filter -// are set, then only items matching the product_filter for requests with a -// query matching the query terms wil get boosted. -message Condition { - // Query terms that we want to match on. - message QueryTerm { - // The value of the term to match on. - // Value cannot be empty. - // Value can have at most 3 terms if specified as a partial match. Each - // space separated string is considered as one term. - // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not - // allowed for partial match. - string value = 1; - - // Whether this is supposed to be a full or partial match. - bool full_match = 2; - } - - // Used for time-dependent conditions. - // Example: Want to have rule applied for week long sale. - message TimeRange { - // Start of time range. Range is inclusive. - google.protobuf.Timestamp start_time = 1; - - // End of time range. Range is inclusive. - google.protobuf.Timestamp end_time = 2; - } - - // A list (up to 10 entries) of terms to match the query on. If not - // specified, match all queries. - // If many query terms are specified, the condition - // is matched if any of the terms is a match (i.e. using the OR operator). - repeated QueryTerm query_terms = 1; - - // Range of time(s) specifying when Condition is active. - // Condition true if any time range matches. - repeated TimeRange active_time_range = 3; -} - -// A rule is a condition-action pair -// * A condition defines when a rule is to be triggered. -// * An action specifies what occurs on that trigger. -// Currently only boost rules are supported. -// Currently only supported by the search endpoint. -message Rule { - // A boost action to apply to results matching condition specified above. - message BoostAction { - // Strength of the condition boost, which must be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 1; - - // The filter can have a max size of 5000 characters. - // An expression which specifies which products to apply an action to. - // The syntax and supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue":
- // *(id: ANY("product_1", "product_2"))
* - // *AND
* - // *(colorFamilies: ANY("Red", "Blue"))
* - string products_filter = 2; - } - - // * Rule Condition: - // - No [Condition][query_terms] provided is a global match. - // - 1 or more [Condition][query_terms] provided is combined with OR - // operator. - // * Action Input: The request query and filter that will be applied to the - // retrieved products, in addition to any filters already provided with the - // SearchRequest. The AND operator is used to combine the query's existing - // filters with the filter rule(s). NOTE: May result in 0 results when - // filters conflict. - // * Action Result: Filters the returned objects to be ONLY those that passed - // the filter. - message FilterAction { - // A filter to apply on the matching condition results. Supported features: - // - // * [filter][google.cloud.retail.v2beta.Rule.FilterAction.filter] must be - // set. - // * Filter syntax is identical to - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter]. - // See more - // details at the Retail Search - // [user guide](/retail/search/docs/filter-and-order#filter). - // * To filter products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue":
- // *(id: ANY("product_1", "product_2"))
* - // *AND
* - // *(colorFamilies: ANY("Red", "Blue"))
* - string filter = 1; - } - - // Redirects a shopper to a specific page. - // * Rule Condition: - // - Must specify [Condition][query_terms]. - // * Action Input: Request Query - // * Action Result: Redirects shopper to provided uri. - message RedirectAction { - // URL must have length equal or less than 2000 characters. - string redirect_uri = 1; - } - - // Creates a set of terms that will be treated as synonyms of each other. - // Example: synonyms of "sneakers" and "shoes". - // * "sneakers" will use a synonym of "shoes". - // * "shoes" will use a synonym of "sneakers". - message TwowaySynonymsAction { - // Defines a set of synonyms. - // Can specify up to 100 synonyms. - // Must specify at least 2 synonyms. - repeated string synonyms = 1; - } - - // Maps a set of terms to a set of synonyms. - // Set of synonyms will be treated as synonyms of each query term only. - // `query_terms` will not be treated as synonyms of each other. - // Example: "sneakers" will use a synonym of "shoes". - // "shoes" will not use a synonym of "sneakers". - message OnewaySynonymsAction { - // Terms from the search query. - // Will treat synonyms as their synonyms. - // Not themselves synonyms of the synonyms. - // Can specify up to 100 terms. - repeated string query_terms = 3; - - // Defines a set of synonyms. - // Cannot contain duplicates. - // Can specify up to 100 synonyms. - repeated string synonyms = 4; - - // Will be [deprecated = true] post migration; - repeated string oneway_terms = 2; - } - - // Prevents `query_term` from being associated with specified terms during - // search. - // Example: Don't associate "gShoe" and "cheap". - message DoNotAssociateAction { - // Terms from the search query. - // Will not consider do_not_associate_terms for search if in search query. - // Can specify up to 100 terms. - repeated string query_terms = 2; - - // Cannot contain duplicates or the query term. - // Can specify up to 100 terms. - repeated string do_not_associate_terms = 3; - - // Will be [deprecated = true] post migration; - repeated string terms = 1; - } - - // Replaces a term in the query. Multiple replacement candidates can be - // specified. All `query_terms` will be replaced with the replacement term. - // Example: Replace "gShoe" with "google shoe". - message ReplacementAction { - // Terms from the search query. - // Will be replaced by replacement term. - // Can specify up to 100 terms. - repeated string query_terms = 2; - - // Term that will be used for replacement. - string replacement_term = 3; - - // Will be [deprecated = true] post migration; - string term = 1; - } - - // Prevents a term in the query from being used in search. - // Example: Don't search for "shoddy". - message IgnoreAction { - // Terms to ignore in the search query. - repeated string ignore_terms = 1; - } - - // An action must be provided. - oneof action { - // A boost action. - BoostAction boost_action = 2; - - // Redirects a shopper to a specific page. - RedirectAction redirect_action = 3; - - // Treats specific term as a synonym with a group of terms. - // Group of terms will not be treated as synonyms with the specific term. - OnewaySynonymsAction oneway_synonyms_action = 6; - - // Prevents term from being associated with other terms. - DoNotAssociateAction do_not_associate_action = 7; - - // Replaces specific terms in the query. - ReplacementAction replacement_action = 8; - - // Ignores specific terms from query during search. - IgnoreAction ignore_action = 9; - - // Filters results. - FilterAction filter_action = 10; - - // Treats a set of terms as synonyms of one another. - TwowaySynonymsAction twoway_synonyms_action = 11; - } - - // Required. The condition that triggers the rule. - // If the condition is empty, the rule will always apply. - Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// An intended audience of the [Product][google.cloud.retail.v2beta.Product] for -// whom it's sold. -message Audience { - // The genders of the audience. Strongly encouraged to use the standard - // values: "male", "female", "unisex". - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [gender](https://support.google.com/merchants/answer/6324479). Schema.org - // property - // [Product.audience.suggestedGender](https://schema.org/suggestedGender). - repeated string genders = 1; - - // The age groups of the audience. Strongly encouraged to use the standard - // values: "newborn" (up to 3 months old), "infant" (3–12 months old), - // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically - // teens or older). - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [age_group](https://support.google.com/merchants/answer/6324463). - // Schema.org property - // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and - // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). - repeated string age_groups = 2; -} - -// The color information of a [Product][google.cloud.retail.v2beta.Product]. -message ColorInfo { - // The standard color families. Strongly recommended to use the following - // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", - // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and - // "Mixed". Normally it is expected to have only 1 color family. May consider - // using single "Mixed" instead of multiple values. - // - // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string color_families = 1; - - // The color display names, which may be different from standard color family - // names, such as the color aliases used in the website frontend. Normally - // it is expected to have only 1 color. May consider using single "Mixed" - // instead of multiple values. - // - // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string colors = 2; -} - -// A custom attribute that is not explicitly modeled in -// [Product][google.cloud.retail.v2beta.Product]. -message CustomAttribute { - // The textual values of this custom attribute. For example, `["yellow", - // "green"]` when the key is "color". - // - // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be - // set. Otherwise, an INVALID_ARGUMENT error is returned. - repeated string text = 1; - - // The numerical values of this custom attribute. For example, `[2.3, 15.4]` - // when the key is "lengths_cm". - // - // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be - // set. Otherwise, an INVALID_ARGUMENT error is returned. - repeated double numbers = 2; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2beta.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // This field is ignored in a - // [UserEvent][google.cloud.retail.v2beta.UserEvent]. - // - // Only set if type [text][google.cloud.retail.v2beta.CustomAttribute.text] is - // set. Otherwise, a INVALID_ARGUMENT error is returned. - optional bool searchable = 3; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2beta.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // indexed, so that it can be filtered, faceted or boosted in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // This field is ignored in a - // [UserEvent][google.cloud.retail.v2beta.UserEvent]. - // - // See - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter], - // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] - // and - // [SearchRequest.boost_spec][google.cloud.retail.v2beta.SearchRequest.boost_spec] - // for more details. - optional bool indexable = 4; -} - -// Fulfillment information, such as the store IDs for in-store pickup or region -// IDs for different shipping methods. -message FulfillmentInfo { - // The fulfillment type, including commonly used types (such as pickup in - // store and same day delivery), and custom types. Customers have to map - // custom types to their display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - string type = 1; - - // The IDs for this [type][google.cloud.retail.v2beta.FulfillmentInfo.type], - // such as the store IDs for - // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2beta.FulfillmentInfo.type] - // or the region IDs for - // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2beta.FulfillmentInfo.type]. - // - // A maximum of 3000 values are allowed. Each value must be a string with a - // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such - // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string place_ids = 2; -} - -// [Product][google.cloud.retail.v2beta.Product] image. Recommendations AI and -// Retail Search do not use product images to improve prediction and search -// results. However, product images can be returned in results, and are shown in -// prediction or search previews in the console. -message Image { - // Required. URI of the image. - // - // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // Height of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 height = 2; - - // Width of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 width = 3; -} - -// A floating point interval. -message Interval { - // The lower bound of the interval. If neither of the min fields are set, then - // the lower bound is negative infinity. - // - // This field must be not larger than - // [max][google.cloud.retail.v2beta.Interval.max]. Otherwise, an - // INVALID_ARGUMENT error is returned. - oneof min { - // Inclusive lower bound. - double minimum = 1; - - // Exclusive lower bound. - double exclusive_minimum = 2; - } - - // The upper bound of the interval. If neither of the max fields are set, then - // the upper bound is positive infinity. - // - // This field must be not smaller than - // [min][google.cloud.retail.v2beta.Interval.min]. Otherwise, an - // INVALID_ARGUMENT error is returned. - oneof max { - // Inclusive upper bound. - double maximum = 3; - - // Exclusive upper bound. - double exclusive_maximum = 4; - } -} - -// The price information of a [Product][google.cloud.retail.v2beta.Product]. -message PriceInfo { - // The price range of all - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. - message PriceRange { - // The inclusive - // [Product.pricing_info.price][google.cloud.retail.v2beta.PriceInfo.price] - // interval of all - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. - Interval price = 1; - - // The inclusive - // [Product.pricing_info.original_price][google.cloud.retail.v2beta.PriceInfo.original_price] - // internal of all - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. - Interval original_price = 2; - } - - // The 3-letter currency code defined in [ISO - // 4217](https://www.iso.org/iso-4217-currency-codes.html). - // - // If this field is an unrecognizable currency code, an INVALID_ARGUMENT - // error is returned. - // - // The [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s with the same - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] - // must share the same - // [currency_code][google.cloud.retail.v2beta.PriceInfo.currency_code]. - // Otherwise, a FAILED_PRECONDITION error is returned. - string currency_code = 1; - - // Price of the product. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). Schema.org - // property [Offer.price](https://schema.org/price). - float price = 2; - - // Price of the product without any discount. If zero, by default set to be - // the [price][google.cloud.retail.v2beta.PriceInfo.price]. - float original_price = 3; - - // The costs associated with the sale of a particular product. Used for gross - // profit reporting. - // - // * Profit = [price][google.cloud.retail.v2beta.PriceInfo.price] - - // [cost][google.cloud.retail.v2beta.PriceInfo.cost] - // - // Google Merchant Center property - // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). - float cost = 4; - - // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] - // starts to be effective. This can be set as a future timestamp, and the - // [price][google.cloud.retail.v2beta.PriceInfo.price] is only used for search - // after - // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. - // If so, the - // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must - // be set and - // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is - // used before - // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. - // - // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always - // effective because it will cause additional latency during search. - google.protobuf.Timestamp price_effective_time = 5; - - // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] - // stops to be effective. The - // [price][google.cloud.retail.v2beta.PriceInfo.price] is used for search - // before - // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. - // If this field is set, the - // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must - // be set and - // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is - // used after - // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. - // - // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always - // effective because it will cause additional latency during search. - google.protobuf.Timestamp price_expire_time = 6; - - // Output only. The price range of all the child - // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s grouped together on the - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]. Only populated for - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. - // Do not set this field in API requests. - PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The rating of a [Product][google.cloud.retail.v2beta.Product]. -message Rating { - // The total number of ratings. This value is independent of the value of - // [rating_histogram][google.cloud.retail.v2beta.Rating.rating_histogram]. - // - // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 rating_count = 1; - - // The average rating of the [Product][google.cloud.retail.v2beta.Product]. - // - // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is - // returned. - float average_rating = 2; - - // List of rating counts per rating value (index = rating - 1). The list is - // empty if there is no rating. If the list is non-empty, its size is - // always 5. Otherwise, an INVALID_ARGUMENT error is returned. - // - // For example, [41, 14, 13, 47, 303]. It means that the - // [Product][google.cloud.retail.v2beta.Product] got 41 ratings with 1 star, - // 14 ratings with 2 star, and so on. - repeated int32 rating_histogram = 3; -} - -// Information of an end user. -message UserInfo { - // Highly recommended for logged-in users. Unique identifier for logged-in - // user, such as a user name. - // - // Always use a hashed value for this ID. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string user_id = 1; - - // The end user's IP address. This field is used to extract location - // information for personalization. - // - // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 - // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This should not be set when: - // - // * setting - // [SearchRequest.user_info][google.cloud.retail.v2beta.SearchRequest.user_info]. - // * using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] - // is set. - string ip_address = 2; - - // User agent as included in the HTTP header. Required for getting - // [SearchResponse.sponsored_results][google.cloud.retail.v2beta.SearchResponse.sponsored_results]. - // - // The field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This should not be set when using the client side event reporting with - // GTM or JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] - // is set. - string user_agent = 3; - - // True if the request is made directly from the end user, in which case the - // [ip_address][google.cloud.retail.v2beta.UserInfo.ip_address] and - // [user_agent][google.cloud.retail.v2beta.UserInfo.user_agent] can be - // populated from the HTTP request. This flag should be set only if the API - // request is made directly from the end user such as a mobile app (and not if - // a gateway or a server is processing and pushing the user events). - // - // This should not be set when using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent]. - bool direct_user_request = 4; -} - -// The inventory information at a place (e.g. a store) identified -// by a place ID. -message LocalInventory { - // The place ID for the current set of inventory information. - string place_id = 1; - - // Product price and cost information. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 2; - - // Additional local inventory attributes, for example, store name, promotion - // tags, etc. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * At most 30 attributes are allowed. - // * The key must be a UTF-8 encoded string with a length limit of 32 - // characters. - // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, - // key0LikeThis or KEY_1_LIKE_THIS. - // * The attribute values must be of the same type (text or number). - // * Only 1 value is allowed for each attribute. - // * For text values, the length limit is 256 UTF-8 characters. - // * The attribute does not support search. The `searchable` field should be - // unset or set to false. - // * The max summed total bytes of custom attribute keys and values per - // product is 5MiB. - map attributes = 3; - - // Input only. Supported fulfillment types. Valid fulfillment type values - // include commonly used types (such as pickup in store and same day - // delivery), and custom types. Customers have to map custom types to their - // display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string fulfillment_types = 4 - [(google.api.field_behavior) = INPUT_ONLY]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto deleted file mode 100644 index 6a1f2907..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/import_config.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "CompletionServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Auto-completion service for retail. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service CompletionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Completes the specified prefix with keyword suggestions. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { - option (google.api.http) = { - get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" - }; - } - - // Bulk import of processed completion dataset. - // - // Request processing is asynchronous. Partial updating is not supported. - // - // The operation is successfully finished only after the imported suggestions - // are indexed successfully and ready for serving. The process takes hours. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc ImportCompletionData(ImportCompletionDataRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.ImportCompletionDataResponse" - metadata_type: "google.cloud.retail.v2beta.ImportMetadata" - }; - } -} - -// Auto-complete parameters. -message CompleteQueryRequest { - // Required. Catalog for which the completion is performed. - // - // Full resource name of catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The query used to generate suggestions. - // - // The maximum number of allowed characters is 255. - string query = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required field. A unique identifier for tracking visitors. For example, - // this could be implemented with an HTTP cookie, which should be able to - // uniquely identify a visitor on a single device. This unique identifier - // should not change if the visitor logs in or out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 7; - - // The language filters applied to the output suggestions. If set, it should - // contain the language of the query. If not set, suggestions are returned - // without considering language restrictions. This is the BCP-47 language - // code, such as "en-US" or "sr-Latn". For more information, see [Tags for - // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - // number of language codes is 3. - repeated string language_codes = 3; - - // The device type context for completion suggestions. - // It is useful to apply different suggestions on different device types, e.g. - // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - // types. - // - // Supported formats: - // - // * `UNKNOWN_DEVICE_TYPE` - // - // * `DESKTOP` - // - // * `MOBILE` - // - // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - string device_type = 4; - - // Determines which dataset to use for fetching completion. "user-data" will - // use the imported dataset through - // [CompletionService.ImportCompletionData][google.cloud.retail.v2beta.CompletionService.ImportCompletionData]. - // "cloud-retail" will use the dataset generated by cloud retail based on user - // events. If leave empty, it will use the "user-data". - // - // Current supported values: - // - // * user-data - // - // * cloud-retail - // This option requires additional allowlisting. Before using cloud-retail, - // contact Cloud Retail support team first. - string dataset = 6; - - // Completion max suggestions. If left unset or set to 0, then will fallback - // to the configured value - // [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions]. - // - // The maximum allowed max suggestions is 20. If it is set higher, it will be - // capped by 20. - int32 max_suggestions = 5; -} - -// Response of the auto-complete query. -message CompleteQueryResponse { - // Resource that represents completion results. - message CompletionResult { - // The suggestion for the query. - string suggestion = 1; - - // Custom attributes for the suggestion term. - // * For "user-data", the attributes are additional custom attributes - // ingested through BigQuery. - // * For "cloud-retail", the attributes are product attributes generated - // by Cloud Retail. - map attributes = 2; - } - - // Recent search of this user. - message RecentSearchResult { - // The recent search query. - string recent_search = 1; - } - - // Results of the matching suggestions. The result list is ordered and the - // first result is top suggestion. - repeated CompletionResult completion_results = 1; - - // A unique complete token. This should be included in the - // [UserEvent.completion_detail][google.cloud.retail.v2beta.UserEvent.completion_detail] - // for search events resulting from this completion, which enables accurate - // attribution of complete model performance. - string attribution_token = 2; - - // Matched recent searches of this user. The maximum number of recent searches - // is 10. This field is a restricted feature. Contact Retail Search support - // team if you are interested in enabling it. - // - // This feature is only available when - // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2beta.CompleteQueryRequest.visitor_id] - // field is set and [UserEvent][google.cloud.retail.v2beta.UserEvent] is - // imported. The recent searches satisfy the follow rules: - // * They are ordered from latest to oldest. - // * They are matched with - // [CompleteQueryRequest.query][google.cloud.retail.v2beta.CompleteQueryRequest.query] - // case insensitively. - // * They are transformed to lower cases. - // * They are UTF-8 safe. - // - // Recent searches are deduplicated. More recent searches will be reserved - // when duplication happens. - repeated RecentSearchResult recent_search_results = 3; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto deleted file mode 100644 index e5562227..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/search_service.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ControlProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Configures dynamic serving time metadata that is used to pre and post -// process search/recommendation model results. -message Control { - option (google.api.resource) = { - type: "retail.googleapis.com/Control" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" - }; - - // The behavior/type of the control - // - // A behavior/type must be specified on creation. Type cannot be changed once - // specified (e.g. A Rule control will always be a Rule control.). An - // INVALID_ARGUMENT will be returned if either condition is violated. - oneof control { - // A facet specification to perform faceted search. - SearchRequest.FacetSpec facet_spec = 3; - - // A rule control - a condition-action pair. - // Enacts a set action when the condition is triggered. - // For example: Boost "gShoe" when query full matches "Running Shoes". - Rule rule = 4; - } - - // Immutable. Fully qualified name - // projects/*/locations/global/catalogs/*/controls/* - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. The human readable control display name. Used in Retail UI. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is thrown. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Output only. List of serving configuration ids that that are associated - // with this control. Note the association is managed via the ServingConfig, - // this is an output only denormalizeed view. Assumed to be in the same - // catalog. - repeated string associated_serving_config_ids = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Immutable. The solution types that the serving config is used - // for. Currently we support setting only one type of solution at creation - // time. - // - // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. - // If no solution type is provided at creation time, will default to - // SOLUTION_TYPE_SEARCH. - repeated SolutionType solution_types = 6 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto deleted file mode 100644 index 922c46f2..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/control.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ControlServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for modifying Control. -service ControlService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a Control. - // - // If the [Control][google.cloud.retail.v2beta.Control] to create already - // exists, an ALREADY_EXISTS error is returned. - rpc CreateControl(CreateControlRequest) returns (Control) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" - body: "control" - }; - option (google.api.method_signature) = "parent,control,control_id"; - } - - // Deletes a Control. - // - // If the [Control][google.cloud.retail.v2beta.Control] to delete does not - // exist, a NOT_FOUND error is returned. - rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a Control. - // - // [Control][google.cloud.retail.v2beta.Control] cannot be set to a different - // oneof field, if so an INVALID_ARGUMENT is returned. If the - // [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a - // NOT_FOUND error is returned. - rpc UpdateControl(UpdateControlRequest) returns (Control) { - option (google.api.http) = { - patch: "/v2beta/{control.name=projects/*/locations/*/catalogs/*/controls/*}" - body: "control" - }; - option (google.api.method_signature) = "control,update_mask"; - } - - // Gets a Control. - rpc GetControl(GetControlRequest) returns (Control) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all Controls linked to this catalog. - rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Request for CreateControl method. -message CreateControlRequest { - // Required. Full resource name of parent catalog. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The Control to create. - Control control = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the Control, which will become the final - // component of the Control's resource name. - // - // This value should be 4-63 characters, and valid characters - // are /[a-z][0-9]-_/. - string control_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for UpdateControl method. -message UpdateControlRequest { - // Required. The Control to update. - Control control = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Control][google.cloud.retail.v2beta.Control] to update. The following are - // NOT supported: - // - // * [Control.name][google.cloud.retail.v2beta.Control.name] - // - // If not set or empty, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for DeleteControl method. -message DeleteControlRequest { - // Required. The resource name of the Control to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } - ]; -} - -// Request for GetControl method. -message GetControlRequest { - // Required. The resource name of the Control to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } - ]; -} - -// Request for ListControls method. -message ListControlsRequest { - // Required. The catalog resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Optional. Maximum number of results to return. If unspecified, defaults - // to 50. Max allowed value is 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListControls` call. - // Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2beta.ListControlsRequest.filter] is unset. - // * List controls that are used in a single ServingConfig: - // 'serving_config = "boosted_home_page_cvr"' - string filter = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for ListControls method. -message ListControlsResponse { - // All the Controls for a given catalog. - repeated Control controls = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto deleted file mode 100644 index 249f5011..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ExportConfigProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Configuration of destination for Export related errors. -message ExportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage path for import errors. This must be an empty, - // existing Cloud Storage bucket. Export errors will be written to a file in - // this bucket, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Metadata related to the progress of the Export operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ExportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} - -// Response of the ExportProductsRequest. If the long running -// operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ExportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ExportErrorsConfig errors_config = 2; -} - -// Response of the ExportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ExportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ExportErrorsConfig errors_config = 2; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto deleted file mode 100644 index c1390ab0..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/product.proto"; -import "google/cloud/retail/v2beta/user_event.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ImportConfigProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Google Cloud Storage location for input content. -// format. -message GcsSource { - // Required. Google Cloud Storage URIs to input files. URI can be up to - // 2000 characters long. URIs can match the full object path (for example, - // `gs://bucket/directory/object.json`) or a pattern matching one or more - // files, such as `gs://bucket/directory/*.json`. A request can - // contain at most 100 files, and each file can be up to 2 GB. See - // [Importing product - // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) - // for the expected file format and setup instructions. - repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON - // [Product][google.cloud.retail.v2beta.Product] per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. - // * `user_event_ga360`: Using - // https://support.google.com/analytics/answer/3437719. - // - // Supported values for control imports: - // - // * 'control' (default): One JSON - // [Control][google.cloud.retail.v2beta.Control] per line. - // - // Supported values for catalog attribute imports: - // - // * 'catalog_attribute' (default): One CSV - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] per line. - string data_schema = 2; -} - -// BigQuery source import data from. -message BigQuerySource { - // BigQuery table partition info. Leave this empty if the BigQuery table - // is not partitioned. - oneof partition { - // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - google.type.Date partition_date = 6; - } - - // The project ID (can be project # or ID) that the BigQuery source is in with - // a length limit of 128 characters. If not specified, inherits the project - // ID from the parent request. - string project_id = 5; - - // Required. The BigQuery data set to copy the data from with a length limit - // of 1,024 characters. - string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The BigQuery table to copy the data from with a length limit of - // 1,024 characters. - string table_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Intermediate Cloud Storage directory used for the import with a length - // limit of 2,000 characters. Can be specified if one wants to have the - // BigQuery export to a specific Cloud Storage directory. - string gcs_staging_dir = 3; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON - // [Product][google.cloud.retail.v2beta.Product] per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. - // * `user_event_ga360`: - // The schema is available here: - // https://support.google.com/analytics/answer/3437719. - // * `user_event_ga4`: This feature is in private preview. Please contact the - // support team for importing Google Analytics 4 events. - // The schema is available here: - // https://support.google.com/analytics/answer/7029846. - // - // Supported values for auto-completion imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - string data_schema = 4; -} - -// The inline source for the input config for ImportProducts method. -message ProductInlineSource { - // Required. A list of products to update/create. Each product must have a - // valid [Product.id][google.cloud.retail.v2beta.Product.id]. Recommended max - // of 100 items. - repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The inline source for the input config for ImportUserEvents method. -message UserEventInlineSource { - // Required. A list of user events to import. Recommended max of 10k items. - repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Configuration of destination for Import related errors. -message ImportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage prefix for import errors. This must be an empty, - // existing Cloud Storage directory. Import errors will be written to - // sharded files in this directory, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Request message for Import methods. -message ImportProductsRequest { - // Indicates how imported products are reconciled with the existing products - // created or imported before. - enum ReconciliationMode { - // Defaults to INCREMENTAL. - RECONCILIATION_MODE_UNSPECIFIED = 0; - - // Inserts new products or updates existing products. - INCREMENTAL = 1; - - // Calculates diff and replaces the entire product dataset. Existing - // products may be deleted if they are not present in the source location. - // - // Can only be set while using - // [BigQuerySource][google.cloud.retail.v2beta.BigQuerySource]. And the - // BigQuery dataset must be created in the data location "us (multiple - // regions in United States)", otherwise a PERMISSION_DENIED error is - // thrown. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - FULL = 2; - } - - // Required. - // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - // - // If no updateMask is specified, requires products.create permission. - // If updateMask is specified, requires products.update permission. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Deprecated. This field has no effect. - string request_id = 6 [deprecated = true]; - - // Required. The desired input location of the data. - ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. - ImportErrorsConfig errors_config = 3; - - // Indicates which fields in the provided imported 'products' to update. If - // not set, will by default update all fields. - google.protobuf.FieldMask update_mask = 4; - - // The mode of reconciliation between existing products and the products to be - // imported. Defaults to - // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. - ReconciliationMode reconciliation_mode = 5; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - string notification_pubsub_topic = 7; -} - -// Request message for the ImportUserEvents request. -message ImportUserEventsRequest { - // Required. `projects/1234/locations/global/catalogs/default_catalog` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - UserEventInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. Cannot be set - // for inline user event imports. - ImportErrorsConfig errors_config = 3; -} - -// Request message for ImportCompletionData methods. -message ImportCompletionDataRequest { - // Required. The catalog which the suggestions dataset belongs to. - // - // Format: `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - CompletionDataInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 3; -} - -// The input config source for products. -message ProductInputConfig { - // Required. The source of the input. - oneof source { - // The Inline source for the input content for products. - ProductInlineSource product_inline_source = 1; - - // Google Cloud Storage location for the input content. - GcsSource gcs_source = 2; - - // BigQuery input source. - BigQuerySource big_query_source = 3; - } -} - -// The input config source for user events. -message UserEventInputConfig { - // The source of the input. - oneof source { - // Required. The Inline source for the input content for UserEvents. - UserEventInlineSource user_event_inline_source = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Google Cloud Storage location for the input content. - GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. BigQuery input source. - BigQuerySource big_query_source = 3 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// The input config source for completion data. -message CompletionDataInputConfig { - // The source of the input. - // - // Supported - // [BigQuerySource.data_schema][google.cloud.retail.v2beta.BigQuerySource.data_schema] - // values for suggestions imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - oneof source { - // Required. BigQuery input source. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - BigQuerySource big_query_source = 1 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// Metadata related to the progress of the Import operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ImportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; - - // Deprecated. This field is never set. - string request_id = 5 [deprecated = true]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 6; -} - -// Response of the -// [ImportProductsRequest][google.cloud.retail.v2beta.ImportProductsRequest]. If -// the long running operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ImportErrorsConfig errors_config = 2; -} - -// Response of the ImportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ImportErrorsConfig errors_config = 2; - - // Aggregated statistics of user event import status. - UserEventImportSummary import_summary = 3; -} - -// A summary of import result. The UserEventImportSummary summarizes -// the import status for user events. -message UserEventImportSummary { - // Count of user events imported with complete existing catalog information. - int64 joined_events_count = 1; - - // Count of user events imported, but with catalog information not found - // in the imported catalog. - int64 unjoined_events_count = 2; -} - -// Response of the -// [ImportCompletionDataRequest][google.cloud.retail.v2beta.ImportCompletionDataRequest]. -// If the long running operation is done, this message is returned by the -// google.longrunning.Operations.response field if the operation is successful. -message ImportCompletionDataResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto deleted file mode 100644 index c5ec1871..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2beta/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "PredictionServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for making recommendation prediction. -service PredictionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Makes a recommendation prediction. - rpc Predict(PredictRequest) returns (PredictResponse) { - option (google.api.http) = { - post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" - body: "*" - }; - } -} - -// Request message for Predict method. -message PredictRequest { - // Required. Full resource name of the format: - // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} - // The ID of the Recommendations AI placement. Before you can request - // predictions from your model, you must create at least one placement for it. - // For more information, see [Managing - // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - // - // The full list of available placements can be seen at - // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Context about the user, what they are looking at and what action - // they took to trigger the predict request. Note that this user event detail - // won't be ingested to userEvent logs. Thus, a separate userEvent write - // request is required for event logging. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // Maximum number of results to return per page. Set this property - // to the number of prediction results needed. If zero, the service will - // choose a reasonable default. The maximum allowed value is 100. Values - // above 100 will be coerced to 100. - int32 page_size = 3; - - // The previous PredictResponse.next_page_token. - string page_token = 4; - - // Filter for restricting prediction results with a length limit of 5,000 - // characters. Accepts values for tags and the `filterOutOfStockItems` flag. - // - // * Tag expressions. Restricts predictions to products that match all of the - // specified tags. Boolean operators `OR` and `NOT` are supported if the - // expression is enclosed in parentheses, and must be separated from the - // tag values by a space. `-"tagA"` is also supported and is equivalent to - // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - // with a size limit of 1,000 characters. - // - // Note: "Recently viewed" models don't support tag filtering at the - // moment. - // - // * filterOutOfStockItems. Restricts predictions to products that do not - // have a - // stockState value of OUT_OF_STOCK. - // - // Examples: - // - // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - // * filterOutOfStockItems tag=(-"promotional") - // * filterOutOfStockItems - // - // If your filter blocks all prediction results, the API will return generic - // (unfiltered) popular products. If you only want results strictly matching - // the filters, set `strictFiltering` to True in `PredictRequest.params` to - // receive empty results instead. - // Note that the API will never return items with storageStatus of "EXPIRED" - // or "DELETED" regardless of filter choices. - string filter = 5; - - // Use validate only mode for this prediction query. If set to true, a - // dummy model will be used that returns arbitrary products. - // Note that the validate only mode should only be used for testing the API, - // or if the model is not ready. - bool validate_only = 6; - - // Additional domain specific parameters for the predictions. - // - // Allowed values: - // - // * `returnProduct`: Boolean. If set to true, the associated product - // object will be returned in the `results.metadata` field in the - // prediction response. - // * `returnScore`: Boolean. If set to true, the prediction 'score' - // corresponding to each returned product will be set in the - // `results.metadata` field in the prediction response. The given - // 'score' indicates the probability of an product being clicked/purchased - // given the user's context and history. - // * `strictFiltering`: Boolean. True by default. If set to false, the service - // will return generic (unfiltered) popular products instead of empty if - // your filter blocks all prediction results. - // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-price-reranking', 'low-price-reranking', - // 'medium-price-reranking', 'high-price-reranking'}. This gives - // request-level control and adjusts prediction results based on product - // price. - // * `diversityLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-diversity', 'low-diversity', - // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - // request-level control and adjusts prediction results based on product - // category. - map params = 7; - - // The labels applied to a resource must meet the following requirements: - // - // * Each resource can have multiple labels, up to a maximum of 64. - // * Each label must be a key-value pair. - // * Keys have a minimum length of 1 character and a maximum length of 63 - // characters, and cannot be empty. Values can be empty, and have a maximum - // length of 63 characters. - // * Keys and values can contain only lowercase letters, numeric characters, - // underscores, and dashes. All characters must use UTF-8 encoding, and - // international characters are allowed. - // * The key portion of a label must be unique. However, you can use the same - // key with multiple resources. - // * Keys must start with a lowercase letter or international character. - // - // See [Google Cloud - // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - // for more details. - map labels = 8; -} - -// Response message for predict method. -message PredictResponse { - // PredictionResult represents the recommendation prediction results. - message PredictionResult { - // ID of the recommended product - string id = 1; - - // Additional product metadata / annotations. - // - // Possible values: - // - // * `product`: JSON representation of the product. Will be set if - // `returnProduct` is set to true in `PredictRequest.params`. - // * `score`: Prediction score in double value. Will be set if - // `returnScore` is set to true in `PredictRequest.params`. - map metadata = 2; - } - - // A list of recommended products. The order represents the ranking (from the - // most relevant product to the least). - repeated PredictionResult results = 1; - - // A unique attribution token. This should be included in the - // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this - // recommendation, which enables accurate attribution of recommendation model - // performance. - string attribution_token = 2; - - // IDs of products in the request that were missing from the inventory. - repeated string missing_ids = 3; - - // True if the validateOnly property was set in the request. - bool validate_only = 4; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto deleted file mode 100644 index 4e6dfec8..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto +++ /dev/null @@ -1,566 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/promotion.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; -option (google.api.resource_definition) = { - type: "retail.googleapis.com/Branch" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" -}; - -// Product captures all metadata information of items to be recommended or -// searched. -message Product { - option (google.api.resource) = { - type: "retail.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" - }; - - // The type of this product. - enum Type { - // Default value. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] - // if unset. - TYPE_UNSPECIFIED = 0; - - // The primary type. - // - // As the primary unit for predicting, indexing and search serving, a - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product] is grouped with multiple - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s. - PRIMARY = 1; - - // The variant type. - // - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s usually share some common - // attributes on the same - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s, but they have variant - // attributes like different colors, sizes and prices, etc. - VARIANT = 2; - - // The collection type. Collection products are bundled - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s or - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s that are sold together, - // such as a jewelry set with necklaces, earrings and rings, etc. - COLLECTION = 3; - } - - // Product availability. If this field is unspecified, the product is - // assumed to be in stock. - enum Availability { - // Default product availability. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK] - // if unset. - AVAILABILITY_UNSPECIFIED = 0; - - // Product in stock. - IN_STOCK = 1; - - // Product out of stock. - OUT_OF_STOCK = 2; - - // Product that is in pre-order state. - PREORDER = 3; - - // Product that is back-ordered (i.e. temporarily out of stock). - BACKORDER = 4; - } - - oneof expiration { - // The timestamp when this product becomes unavailable for - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // If it is set, the [Product][google.cloud.retail.v2beta.Product] is not - // available for - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] - // after [expire_time][google.cloud.retail.v2beta.Product.expire_time]. - // However, the product can still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // [expire_time][google.cloud.retail.v2beta.Product.expire_time] must be - // later than - // [available_time][google.cloud.retail.v2beta.Product.available_time] and - // [publish_time][google.cloud.retail.v2beta.Product.publish_time], - // otherwise an INVALID_ARGUMENT error is thrown. - // - // Corresponding properties: Google Merchant Center property - // [expiration_date](https://support.google.com/merchants/answer/6324499). - google.protobuf.Timestamp expire_time = 16; - - // Input only. The TTL (time to live) of the product. - // - // If it is set, it must be a non-negative value, and - // [expire_time][google.cloud.retail.v2beta.Product.expire_time] is set as - // current timestamp plus [ttl][google.cloud.retail.v2beta.Product.ttl]. The - // derived [expire_time][google.cloud.retail.v2beta.Product.expire_time] is - // returned in the output and [ttl][google.cloud.retail.v2beta.Product.ttl] - // is left blank when retrieving the - // [Product][google.cloud.retail.v2beta.Product]. - // - // If it is set, the product is not available for - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] - // after current timestamp plus - // [ttl][google.cloud.retail.v2beta.Product.ttl]. However, the product can - // still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - google.protobuf.Duration ttl = 17 - [(google.api.field_behavior) = INPUT_ONLY]; - } - - // Immutable. Full resource name of the product, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. [Product][google.cloud.retail.v2beta.Product] identifier, which - // is the final component of [name][google.cloud.retail.v2beta.Product.name]. - // For example, this field is "id_1", if - // [name][google.cloud.retail.v2beta.Product.name] is - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [id](https://support.google.com/merchants/answer/6324405). Schema.org - // property [Product.sku](https://schema.org/sku). - string id = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The type of the product. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] - // if unset. - Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; - - // Variant group identifier. Must be an - // [id][google.cloud.retail.v2beta.Product.id], with the same parent branch - // with this product. Otherwise, an error is thrown. - // - // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s, this field can only be - // empty or set to the same value as - // [id][google.cloud.retail.v2beta.Product.id]. - // - // For VARIANT [Product][google.cloud.retail.v2beta.Product]s, this field - // cannot be empty. A maximum of 2,000 products are allowed to share the same - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [item_group_id](https://support.google.com/merchants/answer/6324507). - // Schema.org property - // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). - string primary_product_id = 4; - - // The [id][google.cloud.retail.v2beta.Product.id] of the collection members - // when [type][google.cloud.retail.v2beta.Product.type] is - // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]. - // - // Non-existent product ids are allowed. - // The [type][google.cloud.retail.v2beta.Product.type] of the members must be - // either [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] or - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] otherwise - // and INVALID_ARGUMENT error is thrown. Should not set it for other types. A - // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is - // return. - repeated string collection_member_ids = 5; - - // The Global Trade Item Number (GTIN) of the product. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Corresponding properties: Google Merchant Center property - // [gtin](https://support.google.com/merchants/answer/6324461). - // Schema.org property - // [Product.isbn](https://schema.org/isbn), - // [Product.gtin8](https://schema.org/gtin8), - // [Product.gtin12](https://schema.org/gtin12), - // [Product.gtin13](https://schema.org/gtin13), or - // [Product.gtin14](https://schema.org/gtin14). - // - // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. - string gtin = 6; - - // Product categories. This field is repeated for supporting one product - // belonging to several parallel categories. Strongly recommended using the - // full path for better search / recommendation quality. - // - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // For example, if a shoes product belongs to both - // ["Shoes & Accessories" -> "Shoes"] and - // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be - // represented as: - // - // "categories": [ - // "Shoes & Accessories > Shoes", - // "Sports & Fitness > Athletic Clothing > Shoes" - // ] - // - // Must be set for - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product] otherwise an INVALID_ARGUMENT - // error is returned. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2beta.Product]. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [google_product_category][mc_google_product_category]. Schema.org property - // [Product.category] (https://schema.org/category). - // - // [mc_google_product_category]: - // https://support.google.com/merchants/answer/6324436 - repeated string categories = 7; - - // Required. Product title. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [title](https://support.google.com/merchants/answer/6324415). Schema.org - // property [Product.name](https://schema.org/name). - string title = 8 [(google.api.field_behavior) = REQUIRED]; - - // The brands of the product. - // - // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded - // string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [brand](https://support.google.com/merchants/answer/6324351). Schema.org - // property [Product.brand](https://schema.org/brand). - repeated string brands = 9; - - // Product description. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [description](https://support.google.com/merchants/answer/6324468). - // Schema.org property [Product.description](https://schema.org/description). - string description = 10; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // - // For product prediction, this field is ignored and the model automatically - // detects the text language. The - // [Product][google.cloud.retail.v2beta.Product] can include text in different - // languages, but duplicating [Product][google.cloud.retail.v2beta.Product]s - // to provide text in multiple languages can result in degraded model - // performance. - // - // For product search this field is in use. It defaults to "en-US" if unset. - string language_code = 11; - - // Highly encouraged. Extra product attributes to be included. For example, - // for products, this could include the store name, vendor, style, color, etc. - // These are very strong signals for recommendation model, thus we highly - // recommend providing the attributes here. - // - // Features that can take on one of a limited number of possible values. Two - // types of features can be set are: - // - // Textual features. some examples would be the brand/maker of a product, or - // country of a customer. Numerical features. Some examples would be the - // height/weight of a product, or age of a customer. - // - // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, - // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} - // }`. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * Max entries count: 200. - // * The key must be a UTF-8 encoded string with a length limit of 128 - // characters. - // * For indexable attribute, the key must match the pattern: - // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or - // `KEY_1_LIKE_THIS`. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a non-empty UTF-8 encoded string with a - // length limit of 256 characters. - // * For number attributes, at most 400 values are allowed. - map attributes = 12; - - // Custom tags associated with the product. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2beta.Product]. This value must be a UTF-8 - // encoded string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This tag can be used for filtering recommendation results by passing the - // tag as part of the - // [PredictRequest.filter][google.cloud.retail.v2beta.PredictRequest.filter]. - // - // Corresponding properties: Google Merchant Center property - // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). - repeated string tags = 13; - - // Product price and cost information. - // - // Corresponding properties: Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 14; - - // The rating of this product. - Rating rating = 15; - - // The timestamp when this [Product][google.cloud.retail.v2beta.Product] - // becomes available for - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - google.protobuf.Timestamp available_time = 18; - - // The online availability of the - // [Product][google.cloud.retail.v2beta.Product]. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK]. - // - // Corresponding properties: Google Merchant Center property - // [availability](https://support.google.com/merchants/answer/6324448). - // Schema.org property [Offer.availability](https://schema.org/availability). - Availability availability = 19; - - // The available quantity of the item. - google.protobuf.Int32Value available_quantity = 20; - - // Fulfillment information, such as the store IDs for in-store pickup or - // region IDs for different shipping methods. - // - // All the elements must have distinct - // [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated FulfillmentInfo fulfillment_info = 21; - - // Canonical URL directly linking to the product detail page. - // - // It is strongly recommended to provide a valid uri for the product, - // otherwise the service performance could be significantly degraded. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [link](https://support.google.com/merchants/answer/6324416). Schema.org - // property [Offer.url](https://schema.org/url). - string uri = 22; - - // Product images for the product. We highly recommend putting the main - // image first. - // - // A maximum of 300 images are allowed. - // - // Corresponding properties: Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - repeated Image images = 23; - - // The target group associated with a given audience (e.g. male, veterans, - // car owners, musicians, etc.) of the product. - Audience audience = 24; - - // The color of the product. - // - // Corresponding properties: Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - ColorInfo color_info = 25; - - // The size of the product. To represent different size systems or size types, - // consider using this format: [[[size_system:]size_type:]size_value]. - // - // For example, in "US:MENS:M", "US" represents size system; "MENS" represents - // size type; "M" represents size value. In "GIRLS:27", size system is empty; - // "GIRLS" represents size type; "27" represents size value. In "32 inches", - // both size system and size type are empty, while size value is "32 inches". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [size](https://support.google.com/merchants/answer/6324492), - // [size_type](https://support.google.com/merchants/answer/6324497), and - // [size_system](https://support.google.com/merchants/answer/6324502). - // Schema.org property [Product.size](https://schema.org/size). - repeated string sizes = 26; - - // The material of the product. For example, "leather", "wooden". - // - // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 200 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [material](https://support.google.com/merchants/answer/6324410). Schema.org - // property [Product.material](https://schema.org/material). - repeated string materials = 27; - - // The pattern or graphic print of the product. For example, "striped", "polka - // dot", "paisley". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org - // property [Product.pattern](https://schema.org/pattern). - repeated string patterns = 28; - - // The condition of the product. Strongly encouraged to use the standard - // values: "new", "refurbished", "used". - // - // A maximum of 1 value is allowed per - // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [condition](https://support.google.com/merchants/answer/6324469). - // Schema.org property - // [Offer.itemCondition](https://schema.org/itemCondition). - repeated string conditions = 29; - - // The promotions applied to the product. A maximum of 10 values are allowed - // per [Product][google.cloud.retail.v2beta.Product]. Only - // [Promotion.promotion_id][google.cloud.retail.v2beta.Promotion.promotion_id] - // will be used, other fields will be ignored if set. - repeated Promotion promotions = 34; - - // The timestamp when the product is published by the retailer for the first - // time, which indicates the freshness of the products. Note that this field - // is different from - // [available_time][google.cloud.retail.v2beta.Product.available_time], given - // it purely describes product freshness regardless of when it is available on - // search and recommendation. - google.protobuf.Timestamp publish_time = 33; - - // Indicates which fields in the - // [Product][google.cloud.retail.v2beta.Product]s are returned in - // [SearchResponse][google.cloud.retail.v2beta.SearchResponse]. - // - // Supported fields for all [type][google.cloud.retail.v2beta.Product.type]s: - // - // * [audience][google.cloud.retail.v2beta.Product.audience] - // * [availability][google.cloud.retail.v2beta.Product.availability] - // * [brands][google.cloud.retail.v2beta.Product.brands] - // * [color_info][google.cloud.retail.v2beta.Product.color_info] - // * [conditions][google.cloud.retail.v2beta.Product.conditions] - // * [gtin][google.cloud.retail.v2beta.Product.gtin] - // * [materials][google.cloud.retail.v2beta.Product.materials] - // * [name][google.cloud.retail.v2beta.Product.name] - // * [patterns][google.cloud.retail.v2beta.Product.patterns] - // * [price_info][google.cloud.retail.v2beta.Product.price_info] - // * [rating][google.cloud.retail.v2beta.Product.rating] - // * [sizes][google.cloud.retail.v2beta.Product.sizes] - // * [title][google.cloud.retail.v2beta.Product.title] - // * [uri][google.cloud.retail.v2beta.Product.uri] - // - // Supported fields only for - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]: - // - // * [categories][google.cloud.retail.v2beta.Product.categories] - // * [description][google.cloud.retail.v2beta.Product.description] - // * [images][google.cloud.retail.v2beta.Product.images] - // - // Supported fields only for - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]: - // - // * Only the first image in - // [images][google.cloud.retail.v2beta.Product.images] - // - // To mark [attributes][google.cloud.retail.v2beta.Product.attributes] as - // retrievable, include paths of the form "attributes.key" where "key" is the - // key of a custom attribute, as specified in - // [attributes][google.cloud.retail.v2beta.Product.attributes]. - // - // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], the - // following fields are always returned in - // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] by default: - // - // * [name][google.cloud.retail.v2beta.Product.name] - // - // For [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT], the - // following fields are always returned in by default: - // - // * [name][google.cloud.retail.v2beta.Product.name] - // * [color_info][google.cloud.retail.v2beta.Product.color_info] - // - // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Note: Returning more fields in - // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] may increase - // response payload size and serving latency. - google.protobuf.FieldMask retrievable_fields = 30; - - // Output only. Product variants grouped together on primary product which - // share similar product attributes. It's automatically grouped by - // [primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] - // for all the product variants. Only populated for - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. - // Do not set this field in API requests. - repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto deleted file mode 100644 index 0ad73436..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto +++ /dev/null @@ -1,829 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/import_config.proto"; -import "google/cloud/retail/v2beta/product.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for ingesting [Product][google.cloud.retail.v2beta.Product] -// information of the customer's website. -service ProductService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a [Product][google.cloud.retail.v2beta.Product]. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Gets a [Product][google.cloud.retail.v2beta.Product]. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Product][google.cloud.retail.v2beta.Product]s. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a [Product][google.cloud.retail.v2beta.Product]. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v2beta/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Deletes a [Product][google.cloud.retail.v2beta.Product]. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. - // - // Request processing may be synchronous. No partial updating is supported. - // Non-existing items are created. - // - // Note that it is possible for a subset of the - // [Product][google.cloud.retail.v2beta.Product]s to be successfully updated. - rpc ImportProducts(ImportProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.ImportProductsResponse" - metadata_type: "google.cloud.retail.v2beta.ImportMetadata" - }; - } - - // Updates inventory information for a - // [Product][google.cloud.retail.v2beta.Product] while respecting the last - // update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2beta.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, updates are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // When inventory is updated with - // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], - // the specified inventory field value(s) will overwrite any existing value(s) - // while ignoring the last update time for this field. Furthermore, the last - // update time for the specified inventory fields will be overwritten to the - // time of the - // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or - // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] - // request. - // - // If no inventory fields are set in - // [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], - // then any pre-existing inventory information for this product will be used. - // - // If no inventory fields are set in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], - // then any existing inventory information will be preserved. - // - // Pre-existing inventory information can only be updated with - // [SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], - // [AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], - // and - // [RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" - body: "*" - }; - option (google.api.method_signature) = "inventory,set_mask"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.SetInventoryResponse" - metadata_type: "google.cloud.retail.v2beta.SetInventoryMetadata" - }; - } - - // Incrementally adds place IDs to - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2beta.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the added place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata" - }; - } - - // Incrementally removes place IDs from a - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2beta.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the removed place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata" - }; - } - - // Updates local inventory information for a - // [Product][google.cloud.retail.v2beta.Product] at a list of places, while - // respecting the last update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2beta.Product] to exist before updating - // inventory information. If the request is valid, the update will be enqueued - // and processed downstream. As a consequence, when a response is returned, - // updates are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // Local inventory information can only be modified using this method. - // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddLocalInventories(AddLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.AddLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2beta.AddLocalInventoriesMetadata" - }; - } - - // Remove local inventory information for a - // [Product][google.cloud.retail.v2beta.Product] at a list of places at a - // removal timestamp. - // - // This process is asynchronous. If the request is valid, the removal will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, removals are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // Local inventory information can only be removed using this method. - // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata" - }; - } -} - -// Request message for [CreateProduct][] method. -message CreateProductRequest { - // Required. The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Required. The [Product][google.cloud.retail.v2beta.Product] to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the - // [Product][google.cloud.retail.v2beta.Product], which will become the final - // component of the [Product.name][google.cloud.retail.v2beta.Product.name]. - // - // If the caller does not have permission to create the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // This field must be unique among all - // [Product][google.cloud.retail.v2beta.Product]s with the same - // [parent][google.cloud.retail.v2beta.CreateProductRequest.parent]. - // Otherwise, an ALREADY_EXISTS error is returned. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string product_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [GetProduct][] method. -message GetProductRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // If the requested [Product][google.cloud.retail.v2beta.Product] does not - // exist, a NOT_FOUND error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for [UpdateProduct][] method. -message UpdateProductRequest { - // Required. The product to update/create. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2beta.Product] to update does not - // exist and - // [allow_missing][google.cloud.retail.v2beta.UpdateProductRequest.allow_missing] - // is not set, a NOT_FOUND error is returned. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Product][google.cloud.retail.v2beta.Product] to update. The immutable and - // output only fields are NOT supported. If not set, all supported fields (the - // fields that are neither immutable nor output only) are updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, a new [Product][google.cloud.retail.v2beta.Product] will be - // created. In this situation, `update_mask` is ignored. - bool allow_missing = 3; -} - -// Request message for [DeleteProduct][] method. -message DeleteProductRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to delete the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2beta.Product] to delete does not - // exist, a NOT_FOUND error is returned. - // - // The [Product][google.cloud.retail.v2beta.Product] to delete can neither be - // a - // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2beta.Product] member nor a - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product] with more than one - // [variants][google.cloud.retail.v2beta.Product.Type.VARIANT]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // All inventory information for the named - // [Product][google.cloud.retail.v2beta.Product] will be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for -// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] -// method. -message ListProductsRequest { - // Required. The parent branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use - // `default_branch` as the branch ID, to list products under the default - // branch. - // - // If the caller does not have permission to list - // [Product][google.cloud.retail.v2beta.Product]s under this branch, - // regardless of whether or not this branch exists, a PERMISSION_DENIED error - // is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. - // If unspecified, defaults to 100. The maximum allowed value is 1000. Values - // above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT error is returned. - int32 page_size = 2; - - // A page token - // [ListProductsResponse.next_page_token][google.cloud.retail.v2beta.ListProductsResponse.next_page_token], - // received from a previous - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; - - // A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2beta.ListProductsRequest.filter] is unset. - // * List - // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s sharing the same - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]. For example: - // `primary_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2beta.Product]s bundled in a - // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2beta.Product]. - // For example: - // `collection_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2beta.Product]s with a partibular - // type. For example: - // `type = "PRIMARY"` - // `type = "VARIANT"` - // `type = "COLLECTION"` - // - // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - // - // If the specified - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product] or - // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2beta.Product] does not exist, a NOT_FOUND - // error is returned. - string filter = 4; - - // The fields of [Product][google.cloud.retail.v2beta.Product] to return in - // the responses. If not set or empty, the following fields are returned: - // - // * [Product.name][google.cloud.retail.v2beta.Product.name] - // * [Product.id][google.cloud.retail.v2beta.Product.id] - // * [Product.title][google.cloud.retail.v2beta.Product.title] - // * [Product.uri][google.cloud.retail.v2beta.Product.uri] - // * [Product.images][google.cloud.retail.v2beta.Product.images] - // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] - // * [Product.brands][google.cloud.retail.v2beta.Product.brands] - // - // If "*" is provided, all fields are returned. - // [Product.name][google.cloud.retail.v2beta.Product.name] is always returned - // no matter what mask is set. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask read_mask = 5; -} - -// Response message for -// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] -// method. -message ListProductsResponse { - // The [Product][google.cloud.retail.v2beta.Product]s. - repeated Product products = 1; - - // A token that can be sent as - // [ListProductsRequest.page_token][google.cloud.retail.v2beta.ListProductsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request message for [SetInventory][] method. -message SetInventoryRequest { - // Required. The inventory information to update. The allowable fields to - // update are: - // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] - // * [Product.availability][google.cloud.retail.v2beta.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] - // The updated inventory fields must be specified in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask]. - // - // If [SetInventoryRequest.inventory.name][] is empty or invalid, an - // INVALID_ARGUMENT error is returned. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2beta.Product] named in - // [Product.name][google.cloud.retail.v2beta.Product.name], regardless of - // whether or not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2beta.Product] to update does not - // have existing inventory information, the provided inventory information - // will be inserted. - // - // If the [Product][google.cloud.retail.v2beta.Product] to update has existing - // inventory information, the provided inventory information will be merged - // while respecting the last update time for each inventory field, using the - // provided or default value for - // [SetInventoryRequest.set_time][google.cloud.retail.v2beta.SetInventoryRequest.set_time]. - // - // The caller can replace place IDs for a subset of fulfillment types in the - // following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types and corresponding place IDs - // to update in [SetInventoryRequest.inventory.fulfillment_info][] - // - // The caller can clear all place IDs from a subset of fulfillment types in - // the following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types to clear in - // [SetInventoryRequest.inventory.fulfillment_info][] - // * Checks that only the desired fulfillment info types have empty - // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] - // - // The last update time is recorded for the following inventory fields: - // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] - // * [Product.availability][google.cloud.retail.v2beta.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] - // - // If a full overwrite of inventory information while ignoring timestamps is - // needed, [UpdateProduct][] should be invoked instead. - Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided - // [Product][google.cloud.retail.v2beta.Product] to update. - // - // At least one field must be provided. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask set_mask = 2; - - // The time when the request is issued, used to prevent - // out-of-order updates on inventory fields with the last update time - // recorded. If not provided, the internal system time will be used. - google.protobuf.Timestamp set_time = 3; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] with - // name [Product.name][google.cloud.retail.v2beta.Product.name] is not found, - // the inventory update will still be processed and retained for at most 1 day - // until the [Product][google.cloud.retail.v2beta.Product] is created. If set - // to false, a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 4; -} - -// Metadata related to the progress of the SetInventory operation. -// Currently empty because there is no meaningful metadata populated from the -// [SetInventory][] method. -message SetInventoryMetadata {} - -// Response of the SetInventoryRequest. Currently empty because -// there is no meaningful response populated from the [SetInventory][] -// method. -message SetInventoryResponse {} - -// Request message for [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type], such - // as the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery" to be added for this - // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type]. - // Duplicate IDs will be automatically ignored. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // If the total number of place IDs exceeds 2000 for this - // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type] after - // adding, then the update will be rejected. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, the fulfillment information will still be processed and retained - // for at most 1 day and processed once the - // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the AddFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesMetadata {} - -// Response of the AddFulfillmentPlacesRequest. Currently empty because -// there is no meaningful response populated from the [AddFulfillmentPlaces][] -// method. -message AddFulfillmentPlacesResponse {} - -// Request message for [AddLocalInventories][] method. -message AddLocalInventoriesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of inventory information at difference places. Each place - // is identified by its place ID. At most 3000 inventories are allowed per - // request. - repeated LocalInventory local_inventories = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided list of - // [LocalInventory][google.cloud.retail.v2beta.LocalInventory] to update. The - // field is updated to the provided value. - // - // If a field is set while the place does not have a previous local inventory, - // the local inventory at that store is created. - // - // If a field is set while the value of that field is not provided, the - // original field value, if it exists, is deleted. - // - // If the mask is not set or set with empty paths, all inventory fields will - // be updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask add_mask = 4; - - // The time when the inventory updates are issued. Used to prevent - // out-of-order updates on local inventory fields. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, the local inventory will still be processed and retained for at - // most 1 day and processed once the - // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 6; -} - -// Metadata related to the progress of the AddLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddLocalInventories][] method. -message AddLocalInventoriesMetadata {} - -// Response of the [AddLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [AddLocalInventories][] -// method. -message AddLocalInventoriesResponse {} - -// Request message for [RemoveLocalInventories][] method. -message RemoveLocalInventoriesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of place IDs to have their inventory deleted. - // At most 3000 place IDs are allowed per request. - repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; - - // The time when the inventory deletions are issued. Used to prevent - // out-of-order updates and deletions on local inventory fields. If not - // provided, the internal system time will be used. - google.protobuf.Timestamp remove_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, the local inventory removal request will still be processed and - // retained for at most 1 day and processed once the - // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 3; -} - -// Metadata related to the progress of the RemoveLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveLocalInventories][] method. -message RemoveLocalInventoriesMetadata {} - -// Response of the [RemoveLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [RemoveLocalInventories][] -// method. -message RemoveLocalInventoriesResponse {} - -// Request message for [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type], - // such as the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery", to be removed for this - // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type]. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp remove_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, the fulfillment information will still be processed and retained - // for at most 1 day and processed once the - // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the RemoveFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesMetadata {} - -// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there -// is no meaningful response populated from the [RemoveFulfillmentPlaces][] -// method. -message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto deleted file mode 100644 index 5346f14d..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "PromotionProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Promotion information. -message Promotion { - // ID of the promotion. For example, "free gift". - // - // The value must be a UTF-8 encoded string with a length limit of 128 - // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, - // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Google Merchant Center property - // [promotion](https://support.google.com/merchants/answer/7050148). - string promotion_id = 1; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto deleted file mode 100644 index 5ab09aa3..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "PurgeConfigProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Metadata related to the progress of the Purge operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeMetadata {} - -// Request message for PurgeUserEvents method. -message PurgeUserEventsRequest { - // Required. The resource name of the catalog under which the events are - // created. The format is - // `projects/${projectId}/locations/global/catalogs/${catalogId}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The filter string to specify the events to be deleted with a - // length limit of 5,000 characters. Empty string filter is not allowed. The - // eligible fields for filtering are: - // - // * `eventType`: Double quoted - // [UserEvent.event_type][google.cloud.retail.v2beta.UserEvent.event_type] - // string. - // * `eventTime`: in ISO 8601 "zulu" format. - // * `visitorId`: Double quoted string. Specifying this will delete all - // events associated with a visitor. - // * `userId`: Double quoted string. Specifying this will delete all events - // associated with a user. - // - // Examples: - // - // * Deleting all events in a time range: - // `eventTime > "2012-04-23T18:25:43.511Z" - // eventTime < "2012-04-23T18:30:43.511Z"` - // * Deleting specific eventType in time range: - // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - // * Deleting all events for a specific visitor: - // `visitorId = "visitor1024"` - // - // The filtering fields are assumed to have an implicit AND. - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually perform the purge. - // If `force` is set to false, the method will return the expected purge count - // without deleting any user events. - bool force = 3; -} - -// Response of the PurgeUserEventsRequest. If the long running operation is -// successfully done, then this message is returned by the -// google.longrunning.Operations.response field. -message PurgeUserEventsResponse { - // The total count of events purged as a result of the operation. - int64 purged_events_count = 1; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto deleted file mode 100644 index b8b2156a..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto +++ /dev/null @@ -1,791 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/product.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "SearchServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for search. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service SearchService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Performs a search. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc Search(SearchRequest) returns (SearchResponse) { - option (google.api.http) = { - post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" - body: "*" - }; - } -} - -// Request message for -// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] -// method. -message SearchRequest { - // A facet specification to perform faceted search. - message FacetSpec { - // Specifies how a facet is computed. - message FacetKey { - // Required. Supported textual and numerical facet keys in - // [Product][google.cloud.retail.v2beta.Product] object, over which the - // facet values are computed. Facet key is case-sensitive. - // - // Allowed facet keys when - // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] - // is not specified: - // - // * textual_field = - // * "brands" - // * "categories" - // * "genders" - // * "ageGroups" - // * "availability" - // * "colorFamilies" - // * "colors" - // * "sizes" - // * "materials" - // * "patterns" - // * "conditions" - // * "attributes.key" - // * "pickupInStore" - // * "shipToStore" - // * "sameDayDelivery" - // * "nextDayDelivery" - // * "customFulfillment1" - // * "customFulfillment2" - // * "customFulfillment3" - // * "customFulfillment4" - // * "customFulfillment5" - // * "inventory(place_id,attributes.key)" - // - // * numerical_field = - // * "price" - // * "discount" - // * "rating" - // * "ratingCount" - // * "attributes.key" - // * "inventory(place_id,price)" - // * "inventory(place_id,original_price)" - // * "inventory(place_id,attributes.key)" - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Set only if values should be bucketized into intervals. Must be set - // for facets with numerical values. Must not be set for facet with text - // values. Maximum number of intervals is 30. - repeated Interval intervals = 2; - - // Only get facet for the given restricted values. For example, when using - // "pickupInStore" as key and set restricted values to - // ["store123", "store456"], only facets for "store123" and "store456" are - // returned. Only supported on textual fields and fulfillments. - // Maximum is 20. - // - // Must be set for the fulfillment facet keys: - // - // * pickupInStore - // - // * shipToStore - // - // * sameDayDelivery - // - // * nextDayDelivery - // - // * customFulfillment1 - // - // * customFulfillment2 - // - // * customFulfillment3 - // - // * customFulfillment4 - // - // * customFulfillment5 - repeated string restricted_values = 3; - - // Only get facet values that start with the given string prefix. For - // example, suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the - // "categories" facet will give only "Women > Shoe" and "Women > Dress". - // Only supported on textual fields. Maximum is 10. - repeated string prefixes = 8; - - // Only get facet values that contains the given strings. For example, - // suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the - // "categories" facet will give only "Women > Shoe" and "Men > Shoe". - // Only supported on textual fields. Maximum is 10. - repeated string contains = 9; - - // The order in which [Facet.values][] are returned. - // - // Allowed values are: - // - // * "count desc", which means order by [Facet.FacetValue.count][] - // descending. - // - // * "value desc", which means order by [Facet.FacetValue.value][] - // descending. - // Only applies to textual facets. - // - // If not set, textual values are sorted in [natural - // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical - // intervals are sorted in the order given by - // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.intervals]; - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // are sorted in the order given by - // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.restricted_values]. - string order_by = 4; - - // The query that is used to compute facet for the given facet key. - // When provided, it will override the default behavior of facet - // computation. The query syntax is the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for detail syntax and limitations. Notice that there is no limitation - // on - // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] - // when query is specified. - // - // In the response, [FacetValue.value][] will be always "1" and - // [FacetValue.count][] will be the number of results that matches the - // query. - // - // For example, you can set a customized facet for "shipToStore", - // where - // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] - // is "customizedShipToStore", and - // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] - // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". - // Then the facet will count the products that are both in stock and ship - // to store "123". - string query = 5; - } - - // Required. The facet key specification. - FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum of facet values that should be returned for this facet. If - // unspecified, defaults to 20. The maximum allowed value is 300. Values - // above 300 will be coerced to 300. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 limit = 2; - - // List of keys to exclude when faceting. - // - // By default, - // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] - // is not excluded from the filter unless it is listed in this field. - // - // For example, suppose there are 100 products with color facet "Red" and - // 200 products with color facet "Blue". A query containing the filter - // "colorFamilies:ANY("Red")" and have "colorFamilies" as - // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] - // will by default return the "Red" with count 100. - // - // If this field contains "colorFamilies", then the query returns both the - // "Red" with count 100 and "Blue" with count 200, because the - // "colorFamilies" key is now excluded from the filter. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated string excluded_filter_keys = 3; - - // Enables dynamic position for this facet. If set to true, the position of - // this facet among all facets in the response is determined by Google - // Retail Search. It will be ordered together with dynamic facets if dynamic - // facets is enabled. If set to false, the position of this facet in the - // response will be the same as in the request, and it will be ranked before - // the facets with dynamic position enable and all dynamic facets. - // - // For example, you may always want to have rating facet returned in - // the response, but it's not necessarily to always display the rating facet - // at the top. In that case, you can set enable_dynamic_position to true so - // that the position of rating facet in response will be determined by - // Google Retail Search. - // - // Another example, assuming you have the following facets in the request: - // - // * "rating", enable_dynamic_position = true - // - // * "price", enable_dynamic_position = false - // - // * "brands", enable_dynamic_position = false - // - // And also you have a dynamic facets enable, which will generate a facet - // 'gender'. Then the final order of the facets in the response can be - // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", - // "rating") depends on how Google Retail Search orders "gender" and - // "rating" facets. However, notice that "price" and "brands" will always be - // ranked at 1st and 2nd position since their enable_dynamic_position are - // false. - bool enable_dynamic_position = 4; - } - - // The specifications of dynamically generated facets. - message DynamicFacetSpec { - // Enum to control DynamicFacet mode - enum Mode { - // Default value. - MODE_UNSPECIFIED = 0; - - // Disable Dynamic Facet. - DISABLED = 1; - - // Automatic mode built by Google Retail Search. - ENABLED = 2; - } - - // Mode of the DynamicFacet feature. - // Defaults to - // [Mode.DISABLED][google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode.DISABLED] - // if it's unset. - Mode mode = 1; - } - - // Boost specification to boost certain items. - message BoostSpec { - // Boost applies to products which match a condition. - message ConditionBoostSpec { - // An expression which specifies a boost condition. The syntax and - // supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue": - // * (id: ANY("product_1", "product_2")) AND (colorFamilies: - // ANY("Red","Blue")) - string condition = 1; - - // Strength of the condition boost, which should be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 2; - } - - // Condition boost specifications. If a product matches multiple conditions - // in the specifictions, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 10. - repeated ConditionBoostSpec condition_boost_specs = 1; - - // Whether to skip boostspec validation. If this field is set to true, - // invalid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] - // will be ignored and valid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] - // will still be applied. - optional bool skip_boost_spec_validation = 2; - } - - // Specification to determine under which conditions query expansion should - // occur. - message QueryExpansionSpec { - // Enum describing under which condition query expansion should occur. - enum Condition { - // Unspecified query expansion condition. This defaults to - // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - CONDITION_UNSPECIFIED = 0; - - // Disabled query expansion. Only the exact search query is used, even if - // [SearchResponse.total_size][google.cloud.retail.v2beta.SearchResponse.total_size] - // is zero. - DISABLED = 1; - - // Automatic query expansion built by Google Retail Search. - AUTO = 3; - } - - // The condition under which query expansion should occur. Default to - // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - Condition condition = 1; - - // Whether to pin unexpanded results. If this field is set to true, - // unexpanded products are always at the top of the search results, followed - // by the expanded results. - bool pin_unexpanded_results = 2; - } - - // The specification for personalization. - message PersonalizationSpec { - // The personalization mode of each search request. - enum Mode { - // Default value. Defaults to - // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Let CRS decide whether to use personalization. - AUTO = 1; - - // Disable personalization. - DISABLED = 2; - } - - // Defaults to - // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. - Mode mode = 1; - } - - // The search mode of each search request. - enum SearchMode { - // Default value. In this case both product search and faceted search will - // be performed. Both [SearchResponse.SearchResult] and - // [SearchResponse.Facet] will be returned. - SEARCH_MODE_UNSPECIFIED = 0; - - // Only product search will be performed. The faceted search will be - // disabled. - // - // Only [SearchResponse.SearchResult] will be returned. - // [SearchResponse.Facet] will not be returned, even if - // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] - // or - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] - // is set. - PRODUCT_SEARCH_ONLY = 1; - - // Only faceted search will be performed. The product search will be - // disabled. - // - // When in this mode, one or both of [SearchRequest.facet_spec][] and - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] - // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only - // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] - // will not be returned. - FACETED_SEARCH_ONLY = 2; - } - - // Required. The resource name of the search engine placement, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` - // This field is used to identify the serving configuration name and the set - // of models that will be used to make the search. - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. - // - // Use "default_branch" as the branch ID or leave this field empty, to search - // products under the default branch. - string branch = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Raw search query. - string query = 3; - - // Required. A unique identifier for tracking visitors. For example, this - // could be implemented with an HTTP cookie, which should be able to uniquely - // identify a visitor on a single device. This unique identifier should not - // change if the visitor logs in or out of the website. - // - // This should be the same identifier as - // [UserEvent.visitor_id][google.cloud.retail.v2beta.UserEvent.visitor_id]. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; - - // User information. - UserInfo user_info = 5; - - // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. - // If unspecified, defaults to a reasonable value. The maximum allowed value - // is 120. Values above 120 will be coerced to 120. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 7; - - // A page token - // [SearchResponse.next_page_token][google.cloud.retail.v2beta.SearchResponse.next_page_token], - // received from a previous - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 8; - - // A 0-indexed integer that specifies the current offset (that is, starting - // result location, amongst the [Product][google.cloud.retail.v2beta.Product]s - // deemed by the API as relevant) in search results. This field is only - // considered if - // [page_token][google.cloud.retail.v2beta.SearchRequest.page_token] is unset. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 offset = 9; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. Filter - // expression is case-sensitive. See more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string filter = 10; - - // The default filter that is applied when a user performs a search without - // checking any filters on the search page. - // - // The filter applied to every search request when quality improvement such as - // query expansion is needed. For example, if a query does not have enough - // results, an expanded query with - // [SearchRequest.canonical_filter][google.cloud.retail.v2beta.SearchRequest.canonical_filter] - // will be returned as a supplement of the original query. This field is - // strongly recommended to achieve high search quality. - // - // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for more details about filter syntax. - string canonical_filter = 28; - - // The order in which products are returned. Products can be ordered by - // a field in an [Product][google.cloud.retail.v2beta.Product] object. Leave - // it unset if ordered by relevance. OrderBy expression is case-sensitive. See - // more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#order). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string order_by = 11; - - // Facet specifications for faceted search. If empty, no facets are returned. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated FacetSpec facet_specs = 12; - - // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - // to enable dynamic facets. Do not set this field. - // - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; - - // Boost specification to boost certain products. See more details at this - // [user guide](https://cloud.google.com/retail/docs/boosting). - // - // Notice that if both - // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] - // and [SearchRequest.boost_spec] are set, the boost conditions from both - // places are evaluated. If a search request matches multiple boost - // conditions, the final boost score is equal to the sum of the boost scores - // from all matched boost conditions. - BoostSpec boost_spec = 13; - - // The query expansion specification that specifies the conditions under which - // query expansion will occur. See more details at this [user - // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - QueryExpansionSpec query_expansion_spec = 14; - - // The keys to fetch and rollup the matching - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s attributes, - // [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo] or - // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s attributes. - // The attributes from all the matching - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s or - // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s are merged and - // de-duplicated. Notice that rollup attributes will lead to extra query - // latency. Maximum number of keys is 30. - // - // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], a - // fulfillment type and a fulfillment ID must be provided in the format of - // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - // "pickupInStore" is fulfillment type and "store123" is the store ID. - // - // Supported keys are: - // - // * colorFamilies - // * price - // * originalPrice - // * discount - // * variantId - // * inventory(place_id,price) - // * inventory(place_id,original_price) - // * inventory(place_id,attributes.key), where key is any key in the - // [Product.inventories.attributes][] map. - // * attributes.key, where key is any key in the - // [Product.attributes][google.cloud.retail.v2beta.Product.attributes] map. - // * pickupInStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "pickup-in-store". - // * shipToStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "ship-to-store". - // * sameDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "same-day-delivery". - // * nextDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "next-day-delivery". - // * customFulfillment1.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-1". - // * customFulfillment2.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-2". - // * customFulfillment3.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-3". - // * customFulfillment4.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-4". - // * customFulfillment5.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-5". - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - repeated string variant_rollup_keys = 17; - - // The categories associated with a category page. Required for category - // navigation queries to achieve good search quality. The format should be - // the same as - // [UserEvent.page_categories][google.cloud.retail.v2beta.UserEvent.page_categories]; - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - repeated string page_categories = 23; - - // The search mode of the search request. If not specified, a single search - // request triggers both product search and faceted search. - SearchMode search_mode = 31; - - // The specification for personalization. - PersonalizationSpec personalization_spec = 32; -} - -// Response message for -// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] -// method. -message SearchResponse { - // Represents the search results. - message SearchResult { - // [Product.id][google.cloud.retail.v2beta.Product.id] of the searched - // [Product][google.cloud.retail.v2beta.Product]. - string id = 1; - - // The product data snippet in the search response. Only - // [Product.name][google.cloud.retail.v2beta.Product.name] is guaranteed to - // be populated. - // - // [Product.variants][google.cloud.retail.v2beta.Product.variants] contains - // the product variants that match the search query. If there are multiple - // product variants matching the query, top 5 most relevant product variants - // are returned and ordered by relevancy. - // - // If relevancy can be deternmined, use - // [matching_variant_fields][google.cloud.retail.v2beta.SearchResponse.SearchResult.matching_variant_fields] - // to look up matched product variants fields. If relevancy cannot be - // determined, e.g. when searching "shoe" all products in a shoe product can - // be a match, 5 product variants are returned but order is meaningless. - Product product = 2; - - // The count of matched - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s. - int32 matching_variant_count = 3; - - // If a [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] matches the search query, - // this map indicates which [Product][google.cloud.retail.v2beta.Product] - // fields are matched. The key is the - // [Product.name][google.cloud.retail.v2beta.Product.name], the value is a - // field mask of the matched [Product][google.cloud.retail.v2beta.Product] - // fields. If matched attributes cannot be determined, this map will be - // empty. - // - // For example, a key "sku1" with field mask - // "products.color_info" indicates there is a match between - // "sku1" [ColorInfo][google.cloud.retail.v2beta.ColorInfo] and the query. - map matching_variant_fields = 4; - - // The rollup matching - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] attributes. The key is one - // of the - // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2beta.SearchRequest.variant_rollup_keys]. - // The values are the merged and de-duplicated - // [Product][google.cloud.retail.v2beta.Product] attributes. Notice that the - // rollup values are respect filter. For example, when filtering by - // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is - // returned. - // - // For textual and numerical attributes, the rollup values is a list of - // string or double values with type - // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if - // there are two variants with colors "red" and "blue", the rollup values - // are - // - // { key: "colorFamilies" - // value { - // list_value { - // values { string_value: "red" } - // values { string_value: "blue" } - // } - // } - // } - // - // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], the - // rollup values is a double value with type - // [google.protobuf.Value][google.protobuf.Value]. For example, - // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there - // are 10 variants in this product are available in the store "store1". - map variant_rollup_values = 5; - } - - // A facet result. - message Facet { - // A facet value which contains value names and their count. - message FacetValue { - // A facet value which contains values. - oneof facet_value { - // Text value of a facet, such as "Black" for facet "colorFamilies". - string value = 1; - - // Interval value for a facet, such as [10, 20) for facet "price". - Interval interval = 2; - } - - // Number of items that have this facet value. - int64 count = 3; - } - - // The key for this facet. E.g., "colorFamilies" or "price" or - // "attributes.attr1". - string key = 1; - - // The facet values for this field. - repeated FacetValue values = 2; - - // Whether the facet is dynamically generated. - bool dynamic_facet = 3; - } - - // Information describing query expansion including whether expansion has - // occurred. - message QueryExpansionInfo { - // Bool describing whether query expansion has occurred. - bool expanded_query = 1; - - // Number of pinned results. This field will only be set when expansion - // happens and - // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] - // is set to true. - int64 pinned_result_count = 2; - } - - // A list of matched items. The order represents the ranking. - repeated SearchResult results = 1; - - // Results of facets requested by user. - repeated Facet facets = 2; - - // The estimated total count of matched items irrespective of pagination. The - // count of [results][google.cloud.retail.v2beta.SearchResponse.results] - // returned by pagination may be less than the - // [total_size][google.cloud.retail.v2beta.SearchResponse.total_size] that - // matches. - int32 total_size = 3; - - // If spell correction applies, the corrected query. Otherwise, empty. - string corrected_query = 4; - - // A unique search token. This should be included in the - // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this - // search, which enables accurate attribution of search model performance. - string attribution_token = 5; - - // A token that can be sent as - // [SearchRequest.page_token][google.cloud.retail.v2beta.SearchRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 6; - - // Query expansion information for the returned results. - QueryExpansionInfo query_expansion_info = 7; - - // The URI of a customer-defined redirect page. If redirect action is - // triggered, no search will be performed, and only - // [redirect_uri][google.cloud.retail.v2beta.SearchResponse.redirect_uri] and - // [attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] - // will be set in the response. - string redirect_uri = 10; - - // The fully qualified resource name of applied - // [controls](https://cloud.google.com/retail/docs/serving-control-rules). - repeated string applied_controls = 12; - - // The invalid - // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] - // that are not applied during serving. - repeated SearchRequest.BoostSpec.ConditionBoostSpec - invalid_condition_boost_specs = 14; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto deleted file mode 100644 index 20112e61..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/search_service.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Configures metadata that is used to generate serving time results (e.g. -// search results or recommendation predictions). -// The ServingConfig is passed in the search and predict request and together -// with the Catalog.default_branch, generates results. -message ServingConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/ServingConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" - }; - - // Immutable. Fully qualified name - // projects/*/locations/global/catalogs/*/servingConfig/* - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. The human readable serving config display name. Used in Retail - // UI. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // The id of the model to use at serving time. - // Currently only RecommendationModels are supported: - // https://cloud.google.com/retail/recommendations-ai/docs/create-models - // Can be changed but only to a compatible model (e.g. - // others-you-may-like CTR to others-you-may-like CVR). - // - // Required when - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string model_id = 3; - - // How much price ranking we want in serving results. - // Price reranking causes product items with a similar - // recommendation probability to be ordered by price, with the - // highest-priced items first. This setting could result in a decrease in - // click-through and conversion rates. - // Allowed values are: - // - // * 'no-price-reranking' - // * 'low-price-raranking' - // * 'medium-price-reranking' - // * 'high-price-reranking' - // - // If not specified, we choose default based on model type. Default value: - // 'no-price-reranking'. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string price_reranking_level = 4; - - // Facet specifications for faceted search. If empty, no facets are returned. - // The ids refer to the ids of [Control][google.cloud.retail.v2beta.Control] - // resources with only the Facet control set. These controls are assumed to be - // in the same [Catalog][google.cloud.retail.v2beta.Catalog] as the - // [ServingConfig][google.cloud.retail.v2beta.ServingConfig]. - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string facet_control_ids = 5; - - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; - - // Condition boost specifications. If a product matches multiple conditions - // in the specifications, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 100. - // - // Notice that if both - // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] - // and [SearchRequest.boost_spec] are set, the boost conditions from both - // places are evaluated. If a search request matches multiple boost - // conditions, the final boost score is equal to the sum of the boost scores - // from all matched boost conditions. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string boost_control_ids = 7; - - // Condition filter specifications. If a product matches multiple conditions - // in the specifications, filters from these specifications are all - // applied and combined via the AND operator. Maximum number of - // specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string filter_control_ids = 9; - - // Condition redirect specifications. Only the first triggered redirect action - // is applied, even if multiple apply. Maximum number of specifications is - // 1000. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string redirect_control_ids = 10; - - // Condition synonyms specifications. If multiple syonyms conditions match, - // all matching synonyms control in the list will execute. Order of controls - // in the list will not matter. Maximum number of specifications is - // 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string twoway_synonyms_control_ids = 18; - - // Condition oneway synonyms specifications. If multiple oneway synonyms - // conditions match, all matching oneway synonyms controls in the list will - // execute. Order of controls in the list will not matter. Maximum number of - // specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string oneway_synonyms_control_ids = 12; - - // Condition do not associate specifications. If multiple do not associate - // conditions match, all matching do not associate controls in the list will - // execute. - // - Order does not matter. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string do_not_associate_control_ids = 13; - - // Condition replacement specifications. - // - Applied according to the order in the list. - // - A previously replaced term can not be re-replaced. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string replacement_control_ids = 14; - - // Condition ignore specifications. If multiple ignore - // conditions match, all matching ignore controls in the list will - // execute. - // - Order does not matter. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string ignore_control_ids = 15; - - // How much diversity to use in recommendation model results e.g. - // 'medium-diversity' or 'high-diversity'. Currently supported values: - // - // * 'no-diversity' - // * 'low-diversity' - // * 'medium-diversity' - // * 'high-diversity' - // * 'auto-diversity' - // - // If not specified, we choose default based on recommendation model - // type. Default value: 'no-diversity'. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string diversity_level = 8; - - // Whether to add additional category filters on the 'similar-items' model. - // If not specified, we enable it by default. - // Allowed values are: - // - // * 'no-category-match': No additional filtering of original results from - // the model and the customer's filters. - // * 'relaxed-category-match': Only keep results with categories that match - // at least one item categories in the PredictRequests's context item. - // * If customer also sends filters in the PredictRequest, then the results - // will satisfy both conditions (user given and category match). - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string enable_category_filter_level = 16; - - // Required. Immutable. Specifies the solution types that a serving config can - // be associated with. Currently we support setting only one type of solution. - repeated SolutionType solution_types = 19 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto deleted file mode 100644 index e56c28ac..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/serving_config.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for modifying ServingConfig. -service ServingConfigService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a ServingConfig. - // - // A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s - // are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise - // a FAILED_PRECONDITION error is returned. - rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" - body: "serving_config" - }; - option (google.api.method_signature) = - "parent,serving_config,serving_config_id"; - } - - // Deletes a ServingConfig. - // - // Returns a NotFound error if the ServingConfig does not exist. - rpc DeleteServingConfig(DeleteServingConfigRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a ServingConfig. - rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - patch: "/v2beta/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - body: "serving_config" - }; - option (google.api.method_signature) = "serving_config,update_mask"; - } - - // Gets a ServingConfig. - // - // Returns a NotFound error if the ServingConfig does not exist. - rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all ServingConfigs linked to this catalog. - rpc ListServingConfigs(ListServingConfigsRequest) - returns (ListServingConfigsResponse) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" - }; - option (google.api.method_signature) = "parent"; - } - - // Enables a Control on the specified ServingConfig. - // The control is added in the last position of the list of controls - // it belongs to (e.g. if it's a facet spec control it will be applied - // in the last position of servingConfig.facetSpecIds) - // Returns a ALREADY_EXISTS error if the control has already been applied. - // Returns a FAILED_PRECONDITION error if the addition could exceed maximum - // number of control allowed for that type of control. - rpc AddControl(AddControlRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" - body: "*" - }; - option (google.api.method_signature) = "serving_config"; - } - - // Disables a Control on the specified ServingConfig. - // The control is removed from the ServingConfig. - // Returns a NOT_FOUND error if the Control is not enabled for the - // ServingConfig. - rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" - body: "*" - }; - option (google.api.method_signature) = "serving_config"; - } -} - -// Request for CreateServingConfig method. -message CreateServingConfigRequest { - // Required. Full resource name of parent. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The ServingConfig to create. - ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the ServingConfig, which will become the final - // component of the ServingConfig's resource name. - // - // This value should be 4-63 characters, and valid characters - // are /[a-z][0-9]-_/. - string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for UpdateServingConfig method. -message UpdateServingConfigRequest { - // Required. The ServingConfig to update. - ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [ServingConfig][google.cloud.retail.v2beta.ServingConfig] to update. The - // following are NOT supported: - // - // * [ServingConfig.name][google.cloud.retail.v2beta.ServingConfig.name] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for DeleteServingConfig method. -message DeleteServingConfigRequest { - // Required. The resource name of the ServingConfig to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; -} - -// Request for GetServingConfig method. -message GetServingConfigRequest { - // Required. The resource name of the ServingConfig to get. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; -} - -// Request for ListServingConfigs method. -message ListServingConfigsRequest { - // Required. The catalog resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Optional. Maximum number of results to return. If unspecified, defaults - // to 100. If a value greater than 100 is provided, at most 100 results are - // returned. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListServingConfigs` call. - // Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for ListServingConfigs method. -message ListServingConfigsResponse { - // All the ServingConfigs for a given catalog. - repeated ServingConfig serving_configs = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} - -// Request for AddControl method. -message AddControlRequest { - // Required. The source ServingConfig resource name . Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; - - // Required. The id of the control to apply. Assumed to be in the same catalog - // as the serving config - if id is not found a NOT_FOUND error is returned. - string control_id = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for RemoveControl method. -message RemoveControlRequest { - // Required. The source ServingConfig resource name . Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; - - // Required. The id of the control to apply. Assumed to be in the same catalog - // as the serving config. - string control_id = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto deleted file mode 100644 index e2175801..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto +++ /dev/null @@ -1,342 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/product.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// UserEvent captures all metadata information Retail API needs to know about -// how end users interact with customers' website. -message UserEvent { - // Required. User event type. Allowed values are: - // - // * `add-to-cart`: Products being added to cart. - // * `category-page-view`: Special pages such as sale or promotion pages - // viewed. - // * `detail-page-view`: Products detail page viewed. - // * `home-page-view`: Homepage viewed. - // * `promotion-offered`: Promotion is offered to a user. - // * `promotion-not-offered`: Promotion is not offered to a user. - // * `purchase-complete`: User finishing a purchase. - // * `search`: Product search. - // * `shopping-cart-page-view`: User viewing a shopping cart. - string event_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A unique identifier for tracking visitors. - // - // For example, this could be implemented with an HTTP cookie, which should be - // able to uniquely identify a visitor on a single device. This unique - // identifier should not change if the visitor log in/out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // The field should not contain PII or user-data. We recommend to use Google - // Analystics [Client - // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) - // for this field. - string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // A unique identifier for tracking a visitor session with a length limit of - // 128 bytes. A session is an aggregation of an end user behavior in a time - // span. - // - // A general guideline to populate the sesion_id: - // 1. If user has no activity for 30 min, a new session_id should be assigned. - // 2. The session_id should be unique across users, suggest use uuid or add - // visitor_id as prefix. - string session_id = 21; - - // Only required for - // [UserEventService.ImportUserEvents][google.cloud.retail.v2beta.UserEventService.ImportUserEvents] - // method. Timestamp of when the user event happened. - google.protobuf.Timestamp event_time = 3; - - // A list of identifiers for the independent experiment groups this user event - // belongs to. This is used to distinguish between user events associated with - // different experiment setups (e.g. using Retail API, using different - // recommendation models). - repeated string experiment_ids = 4; - - // Highly recommended for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. - // This field enables accurate attribution of recommendation model - // performance. - // - // The value must be a valid - // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] - // for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. - // The value must be a valid - // [SearchResponse.attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] - // for user events that are the result of - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // This token enables us to accurately attribute page view or purchase back to - // the event and the particular predict response containing this - // clicked/purchased product. If user clicks on product K in the - // recommendation results, pass - // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] - // as a URL parameter to product K's page. When recording events on product - // K's page, log the - // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] - // to this field. - string attribution_token = 5; - - // The main product details related to the event. - // - // This field is required for the following event types: - // - // * `add-to-cart` - // * `detail-page-view` - // * `purchase-complete` - // * `search` - // - // In a `search` event, this field represents the products returned to the end - // user on the current page (the end user may have not finished browsing the - // whole page yet). When a new page is returned to the end user, after - // pagination/filtering/ordering even for the same query, a new `search` event - // with different - // [product_details][google.cloud.retail.v2beta.UserEvent.product_details] is - // desired. The end user may have not finished browsing the whole page yet. - repeated ProductDetail product_details = 6; - - // The main auto-completion details related to the event. - // - // This field should be set for `search` event when autocomplete function is - // enabled and the user clicks a suggestion for search. - CompletionDetail completion_detail = 22; - - // Extra user event features to include in the recommendation model. - // - // If you provide custom attributes for ingested user events, also include - // them in the user events that you associate with prediction requests. Custom - // attribute formatting must be consistent between imported events and events - // provided with prediction requests. This lets the Retail API use - // those custom attributes when training models and serving predictions, which - // helps improve recommendation quality. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * The key must be a UTF-8 encoded string with a length limit of 5,000 - // characters. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 256 characters. - // * For number attributes, at most 400 values are allowed. - // - // For product recommendations, an example of extra user information is - // traffic_channel, which is how a user arrives at the site. Users can arrive - // at the site by coming to the site directly, coming through Google - // search, or in other ways. - map attributes = 7; - - // The ID or name of the associated shopping cart. This ID is used - // to associate multiple items added or present in the cart before purchase. - // - // This can only be set for `add-to-cart`, `purchase-complete`, or - // `shopping-cart-page-view` events. - string cart_id = 8; - - // A transaction represents the entire purchase transaction. - // - // Required for `purchase-complete` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - PurchaseTransaction purchase_transaction = 9; - - // The user's search query. - // - // See [SearchRequest.query][google.cloud.retail.v2beta.SearchRequest.query] - // for definition. - // - // The value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // At least one of - // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - string search_query = 10; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. - // - // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string filter = 16; - - // The order in which products are returned. - // - // See - // [SearchRequest.order_by][google.cloud.retail.v2beta.SearchRequest.order_by] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string order_by = 17; - - // An integer that specifies the current offset for pagination (the 0-indexed - // starting location, amongst the products deemed by the API as relevant). - // - // See [SearchRequest.offset][google.cloud.retail.v2beta.SearchRequest.offset] - // for definition. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - int32 offset = 18; - - // The categories associated with a category page. - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - // - // Required for `category-page-view` events. At least one of - // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated string page_categories = 11; - - // User information. - UserInfo user_info = 12; - - // Complete URL (window.location.href) of the user's current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. Maximum length 5,000 - // characters. - string uri = 13; - - // The referrer URL of the current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string referrer_uri = 14; - - // A unique ID of a web page view. - // - // This should be kept the same for all user events triggered from the same - // pageview. For example, an item detail page view could trigger multiple - // events as the user is browsing the page. The `pageViewId` property should - // be kept the same for all these events so that they can be grouped together - // properly. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string page_view_id = 15; -} - -// Detailed product information associated with a user event. -message ProductDetail { - // Required. [Product][google.cloud.retail.v2beta.Product] information. - // - // Required field(s): - // - // * [Product.id][google.cloud.retail.v2beta.Product.id] - // - // Optional override field(s): - // - // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] - // - // If any supported optional fields are provided, we will treat them as a full - // override when looking up product information from the catalog. Thus, it is - // important to ensure that the overriding fields are accurate and - // complete. - // - // All other product fields are ignored and instead populated via catalog - // lookup after event ingestion. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Quantity of the product associated with the user event. - // - // For example, this field will be 2 if two products are added to the shopping - // cart for `purchase-complete` event. Required for `add-to-cart` and - // `purchase-complete` event types. - google.protobuf.Int32Value quantity = 2; -} - -// Detailed completion information including completion attribution token and -// clicked completion info. -message CompletionDetail { - // Completion attribution token in - // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2beta.CompleteQueryResponse.attribution_token]. - string completion_attribution_token = 1; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion]. - string selected_suggestion = 2; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion] - // position, starting from 0. - int32 selected_position = 3; -} - -// A transaction represents the entire purchase transaction. -message PurchaseTransaction { - // The transaction ID with a length limit of 128 characters. - string id = 1; - - // Required. Total non-zero revenue or grand total associated with the - // transaction. This value include shipping, tax, or other adjustments to - // total revenue that you want to include as part of your revenue - // calculations. - float revenue = 2 [(google.api.field_behavior) = REQUIRED]; - - // All the taxes associated with the transaction. - float tax = 3; - - // All the costs associated with the products. These can be manufacturing - // costs, shipping expenses not borne by the end user, or any other costs, - // such that: - // - // * Profit = - // [revenue][google.cloud.retail.v2beta.PurchaseTransaction.revenue] - - // [tax][google.cloud.retail.v2beta.PurchaseTransaction.tax] - - // [cost][google.cloud.retail.v2beta.PurchaseTransaction.cost] - float cost = 4; - - // Required. Currency code. Use three-character ISO-4217 code. - string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto deleted file mode 100644 index ab7a0b35..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/httpbody.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/import_config.proto"; -import "google/cloud/retail/v2beta/purge_config.proto"; -import "google/cloud/retail/v2beta/user_event.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for ingesting end user actions on the customer website. -service UserEventService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Writes a single user event. - rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" - body: "user_event" - }; - } - - // Writes a single user event from the browser. This uses a GET request to - // due to browser restriction of POST-ing to a 3rd party domain. - // - // This method is used only by the Retail API JavaScript pixel and Google Tag - // Manager. Users should not call this method directly. - rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" - }; - } - - // Deletes permanently all user events specified by the filter provided. - // Depending on the number of events specified by the filter, this operation - // could take hours or days to complete. To test a filter, use the list - // command first. - rpc PurgeUserEvents(PurgeUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.PurgeUserEventsResponse" - metadata_type: "google.cloud.retail.v2beta.PurgeMetadata" - }; - } - - // Bulk import of User events. Request processing might be - // synchronous. Events that already exist are skipped. - // Use this method for backfilling historical user events. - // - // Operation.response is of type ImportResponse. Note that it is - // possible for a subset of the items to be successfully inserted. - // Operation.metadata is of type ImportMetadata. - rpc ImportUserEvents(ImportUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.ImportUserEventsResponse" - metadata_type: "google.cloud.retail.v2beta.ImportMetadata" - }; - } - - // Starts a user event rejoin operation with latest product catalog. Events - // will not be annotated with detailed product information if product is - // missing from the catalog at the time the user event is ingested, and these - // events are stored as unjoined events with a limited usage on training and - // serving. This method can be used to start a join operation on specified - // events with latest version of product catalog. It can also be used to - // correct events joined with the wrong product catalog. A rejoin operation - // can take hours or days to complete. - rpc RejoinUserEvents(RejoinUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "RejoinUserEventsResponse" - metadata_type: "RejoinUserEventsMetadata" - }; - } -} - -// Request message for WriteUserEvent method. -message WriteUserEventRequest { - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User event to write. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // Required. The parent catalog name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. URL encoded UserEvent proto with a length limit of 2,000,000 - // characters. - string user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // The URL including cgi-parameters but excluding the hash fragment with a - // length limit of 5,000 characters. This is often more useful than the - // referer URL, because many browsers only send the domain for 3rd party - // requests. - string uri = 3; - - // The event timestamp in milliseconds. This prevents browser caching of - // otherwise identical get requests. The name is abbreviated to reduce the - // payload bytes. - int64 ets = 4; -} - -// Request message for RejoinUserEvents method. -message RejoinUserEventsRequest { - // The scope of user events to be rejoined with the latest product catalog. - // If the rejoining aims at reducing number of unjoined events, set - // UserEventRejoinScope to UNJOINED_EVENTS. - // If the rejoining aims at correcting product catalog information in joined - // events, set UserEventRejoinScope to JOINED_EVENTS. - // If all events needs to be rejoined, set UserEventRejoinScope to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. - enum UserEventRejoinScope { - // Rejoin all events with the latest product catalog, including both joined - // events and unjoined events. - USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; - - // Only rejoin joined events with the latest product catalog. - JOINED_EVENTS = 1; - - // Only rejoin unjoined events with the latest product catalog. - UNJOINED_EVENTS = 2; - } - - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The type of the user event rejoin to define the scope and range of the user - // events to be rejoined with the latest product catalog. Defaults to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - // invalid integer value. - UserEventRejoinScope user_event_rejoin_scope = 2; -} - -// Response message for RejoinUserEvents method. -message RejoinUserEventsResponse { - // Number of user events that were joined with latest product catalog. - int64 rejoined_user_events_count = 1; -} - -// Metadata for RejoinUserEvents method. -message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js deleted file mode 100644 index 553e7103..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(attributesConfig, catalogAttribute) { - // [START retail_v2beta_generated_CatalogService_AddCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The - * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to add. - */ - // const catalogAttribute = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callAddCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - catalogAttribute, - }; - - // Run request - const response = await retailClient.addCatalogAttribute(request); - console.log(response); - } - - callAddCatalogAttribute(); - // [END retail_v2beta_generated_CatalogService_AddCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js deleted file mode 100644 index b6c393bd..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_CatalogService_GetAttributesConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const name = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetAttributesConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getAttributesConfig(request); - console.log(response); - } - - callGetAttributesConfig(); - // [END retail_v2beta_generated_CatalogService_GetAttributesConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js deleted file mode 100644 index 886e118a..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_CatalogService_GetCompletionConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full CompletionConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - */ - // const name = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetCompletionConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getCompletionConfig(request); - console.log(response); - } - - callGetCompletionConfig(); - // [END retail_v2beta_generated_CatalogService_GetCompletionConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js deleted file mode 100644 index 11ab8856..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2beta_generated_CatalogService_GetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.getDefaultBranch(request); - console.log(response); - } - - callGetDefaultBranch(); - // [END retail_v2beta_generated_CatalogService_GetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js deleted file mode 100644 index a72872cb..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2beta_generated_CatalogService_ListCatalogs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The account resource name with an associated location. - * If the caller does not have permission to list - * Catalog google.cloud.retail.v2beta.Catalog s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Catalog google.cloud.retail.v2beta.Catalog s to return. - * If unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListCatalogsResponse.next_page_token google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token, - * received from a previous - * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callListCatalogs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listCatalogsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCatalogs(); - // [END retail_v2beta_generated_CatalogService_ListCatalogs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js deleted file mode 100644 index b6d4473a..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(attributesConfig, key) { - // [START retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The attribute name key of the - * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to remove. - */ - // const key = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callRemoveCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - key, - }; - - // Run request - const response = await retailClient.removeCatalogAttribute(request); - console.log(response); - } - - callRemoveCatalogAttribute(); - // [END retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js deleted file mode 100644 index 42548549..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.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(attributesConfig, catalogAttribute) { - // [START retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The updated - * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute. - */ - // const catalogAttribute = {} - /** - * Indicates which fields in the provided - * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to update. - * The following are NOT supported: - * * CatalogAttribute.key google.cloud.retail.v2beta.CatalogAttribute.key - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callReplaceCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - catalogAttribute, - }; - - // Run request - const response = await retailClient.replaceCatalogAttribute(request); - console.log(response); - } - - callReplaceCatalogAttribute(); - // [END retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js deleted file mode 100644 index 11f667df..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2beta_generated_CatalogService_SetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * The final component of the resource name of a branch. - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * If there are no sufficient active products in the targeted branch and - * force google.cloud.retail.v2beta.SetDefaultBranchRequest.force is not - * set, a FAILED_PRECONDITION error is returned. - */ - // const branchId = 'abc123' - /** - * Some note on this request, this can be retrieved by - * CatalogService.GetDefaultBranch google.cloud.retail.v2beta.CatalogService.GetDefaultBranch - * before next valid default branch set occurs. - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const note = 'abc123' - /** - * If set to true, it permits switching to a branch with - * branch_id google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id - * even if it has no sufficient active products. - */ - // const force = true - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callSetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.setDefaultBranch(request); - console.log(response); - } - - callSetDefaultBranch(); - // [END retail_v2beta_generated_CatalogService_SetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js deleted file mode 100644 index dee9a094..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.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(attributesConfig) { - // [START retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The - * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. - */ - // const attributesConfig = {} - /** - * Indicates which fields in the provided - * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. - * The following is the only supported field: - * * AttributesConfig.catalog_attributes google.cloud.retail.v2beta.AttributesConfig.catalog_attributes - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateAttributesConfig() { - // Construct request - const request = { - attributesConfig, - }; - - // Run request - const response = await retailClient.updateAttributesConfig(request); - console.log(response); - } - - callUpdateAttributesConfig(); - // [END retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js deleted file mode 100644 index 3f75b996..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.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(catalog) { - // [START retail_v2beta_generated_CatalogService_UpdateCatalog_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Catalog google.cloud.retail.v2beta.Catalog to update. - * If the caller does not have permission to update the - * Catalog google.cloud.retail.v2beta.Catalog, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * If the Catalog google.cloud.retail.v2beta.Catalog to update does not - * exist, a NOT_FOUND error is returned. - */ - // const catalog = {} - /** - * Indicates which fields in the provided - * Catalog google.cloud.retail.v2beta.Catalog to update. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCatalog() { - // Construct request - const request = { - catalog, - }; - - // Run request - const response = await retailClient.updateCatalog(request); - console.log(response); - } - - callUpdateCatalog(); - // [END retail_v2beta_generated_CatalogService_UpdateCatalog_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js deleted file mode 100644 index d3c451f3..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.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(completionConfig) { - // [START retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The - * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. - * If the caller does not have permission to update the - * CompletionConfig google.cloud.retail.v2beta.CompletionConfig, then a - * PERMISSION_DENIED error is returned. - * If the CompletionConfig google.cloud.retail.v2beta.CompletionConfig to - * update does not exist, a NOT_FOUND error is returned. - */ - // const completionConfig = {} - /** - * Indicates which fields in the provided - * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. - * The following are the only supported fields: - * * CompletionConfig.matching_order google.cloud.retail.v2beta.CompletionConfig.matching_order - * * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions - * * CompletionConfig.min_prefix_length google.cloud.retail.v2beta.CompletionConfig.min_prefix_length - * * CompletionConfig.auto_learning google.cloud.retail.v2beta.CompletionConfig.auto_learning - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCompletionConfig() { - // Construct request - const request = { - completionConfig, - }; - - // Run request - const response = await retailClient.updateCompletionConfig(request); - console.log(response); - } - - callUpdateCompletionConfig(); - // [END retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js deleted file mode 100644 index 28957ff1..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(catalog, query) { - // [START retail_v2beta_generated_CompletionService_CompleteQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Catalog for which the completion is performed. - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * Required. The query used to generate suggestions. - * The maximum number of allowed characters is 255. - */ - // const query = 'abc123' - /** - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see Tags for - * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - */ - // const languageCodes = 'abc123' - /** - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * Supported formats: - * * `UNKNOWN_DEVICE_TYPE` - * * `DESKTOP` - * * `MOBILE` - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - */ - // const deviceType = 'abc123' - /** - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * CompletionService.ImportCompletionData google.cloud.retail.v2beta.CompletionService.ImportCompletionData. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * Current supported values: - * * user-data - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - */ - // const dataset = 'abc123' - /** - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value - * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions. - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - */ - // const maxSuggestions = 1234 - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callCompleteQuery() { - // Construct request - const request = { - catalog, - query, - }; - - // Run request - const response = await retailClient.completeQuery(request); - console.log(response); - } - - callCompleteQuery(); - // [END retail_v2beta_generated_CompletionService_CompleteQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js deleted file mode 100644 index 046aa015..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.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, inputConfig) { - // [START retail_v2beta_generated_CompletionService_ImportCompletionData_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog which the suggestions dataset belongs to. - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callImportCompletionData() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importCompletionData(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportCompletionData(); - // [END retail_v2beta_generated_CompletionService_ImportCompletionData_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js deleted file mode 100644 index 670ed9d8..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.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, control, controlId) { - // [START retail_v2beta_generated_ControlService_CreateControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of parent catalog. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Required. The Control to create. - */ - // const control = {} - /** - * Required. The ID to use for the Control, which will become the final - * component of the Control's resource name. - * This value should be 4-63 characters, and valid characters - * are /[a-z][0-9]-_/. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callCreateControl() { - // Construct request - const request = { - parent, - control, - controlId, - }; - - // Run request - const response = await retailClient.createControl(request); - console.log(response); - } - - callCreateControl(); - // [END retail_v2beta_generated_ControlService_CreateControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js deleted file mode 100644 index fa617382..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ControlService_DeleteControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callDeleteControl() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteControl(request); - console.log(response); - } - - callDeleteControl(); - // [END retail_v2beta_generated_ControlService_DeleteControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js deleted file mode 100644 index dcc21c72..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ControlService_GetControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callGetControl() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getControl(request); - console.log(response); - } - - callGetControl(); - // [END retail_v2beta_generated_ControlService_GetControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js deleted file mode 100644 index 5de3859c..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2beta_generated_ControlService_ListControls_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - /** - * Optional. A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2beta.ListControlsRequest.filter is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - */ - // const filter = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callListControls() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listControlsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListControls(); - // [END retail_v2beta_generated_ControlService_ListControls_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js deleted file mode 100644 index 3bc73051..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(control) { - // [START retail_v2beta_generated_ControlService_UpdateControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Control to update. - */ - // const control = {} - /** - * Indicates which fields in the provided - * Control google.cloud.retail.v2beta.Control to update. The following are - * NOT supported: - * * Control.name google.cloud.retail.v2beta.Control.name - * If not set or empty, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callUpdateControl() { - // Construct request - const request = { - control, - }; - - // Run request - const response = await retailClient.updateControl(request); - console.log(response); - } - - callUpdateControl(); - // [END retail_v2beta_generated_ControlService_UpdateControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js b/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js deleted file mode 100644 index 38b9394c..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, userEvent) { - // [START retail_v2beta_generated_PredictionService_Predict_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see Managing - * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - */ - // const placement = 'abc123' - /** - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - */ - // const userEvent = {} - /** - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - */ - // const pageSize = 1234 - /** - * The previous PredictResponse.next_page_token. - */ - // const pageToken = 'abc123' - /** - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * Examples: - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - */ - // const filter = 'abc123' - /** - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - */ - // const validateOnly = true - /** - * Additional domain specific parameters for the predictions. - * Allowed values: - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - */ - // const params = 1234 - /** - * The labels applied to a resource must meet the following requirements: - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * See Google Cloud - * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - */ - // const labels = 1234 - - // Imports the Retail library - const {PredictionServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new PredictionServiceClient(); - - async function callPredict() { - // Construct request - const request = { - placement, - userEvent, - }; - - // Run request - const response = await retailClient.predict(request); - console.log(response); - } - - callPredict(); - // [END retail_v2beta_generated_PredictionService_Predict_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js deleted file mode 100644 index f25e375d..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type, such - * as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type. - * Duplicate IDs will be automatically ignored. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * If the total number of place IDs exceeds 2000 for this - * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type after - * adding, then the update will be rejected. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * Product google.cloud.retail.v2beta.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddFulfillmentPlaces(); - // [END retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js deleted file mode 100644 index 827fb0fe..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, localInventories) { - // [START retail_v2beta_generated_ProductService_AddLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - */ - // const localInventories = 1234 - /** - * Indicates which inventory fields in the provided list of - * LocalInventory google.cloud.retail.v2beta.LocalInventory to update. The - * field is updated to the provided value. - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const addMask = {} - /** - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, the local inventory will still be processed and retained for at - * most 1 day and processed once the - * Product google.cloud.retail.v2beta.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddLocalInventories() { - // Construct request - const request = { - product, - localInventories, - }; - - // Run request - const [operation] = await retailClient.addLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddLocalInventories(); - // [END retail_v2beta_generated_ProductService_AddLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js deleted file mode 100644 index b6387d2e..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, product, productId) { - // [START retail_v2beta_generated_ProductService_CreateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - */ - // const parent = 'abc123' - /** - * Required. The Product google.cloud.retail.v2beta.Product to create. - */ - // const product = {} - /** - * Required. The ID to use for the - * Product google.cloud.retail.v2beta.Product, which will become the final - * component of the Product.name google.cloud.retail.v2beta.Product.name. - * If the caller does not have permission to create the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * This field must be unique among all - * Product google.cloud.retail.v2beta.Product s with the same - * parent google.cloud.retail.v2beta.CreateProductRequest.parent. - * Otherwise, an ALREADY_EXISTS error is returned. - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const productId = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - productId, - }; - - // Run request - const response = await retailClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END retail_v2beta_generated_ProductService_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js deleted file mode 100644 index 95f4548f..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_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(name) { - // [START retail_v2beta_generated_ProductService_DeleteProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to delete the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2beta.Product to delete does not - * exist, a NOT_FOUND error is returned. - * The Product google.cloud.retail.v2beta.Product to delete can neither be - * a - * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION - * Product google.cloud.retail.v2beta.Product member nor a - * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY - * Product google.cloud.retail.v2beta.Product with more than one - * variants google.cloud.retail.v2beta.Product.Type.VARIANT. Otherwise, an - * INVALID_ARGUMENT error is returned. - * All inventory information for the named - * Product google.cloud.retail.v2beta.Product will be deleted. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END retail_v2beta_generated_ProductService_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js deleted file mode 100644 index d0520d7e..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ProductService_GetProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * If the requested Product google.cloud.retail.v2beta.Product does not - * exist, a NOT_FOUND error is returned. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END retail_v2beta_generated_ProductService_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js deleted file mode 100644 index f7fe86da..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2beta_generated_ProductService_ImportProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. - */ - // const errorsConfig = {} - /** - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - */ - // const updateMask = {} - /** - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * ReconciliationMode.INCREMENTAL google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL. - */ - // const reconciliationMode = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * Only supported when - * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode - * is set to `FULL`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callImportProducts() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProducts(); - // [END retail_v2beta_generated_ProductService_ImportProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js deleted file mode 100644 index d4971483..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2beta_generated_ProductService_ListProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * If the caller does not have permission to list - * Product google.cloud.retail.v2beta.Product s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Product google.cloud.retail.v2beta.Product s to return. - * If unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT error is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListProductsResponse.next_page_token google.cloud.retail.v2beta.ListProductsResponse.next_page_token, - * received from a previous - * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2beta.ListProductsRequest.filter is unset. - * * List - * Product.Type.VARIANT google.cloud.retail.v2beta.Product.Type.VARIANT - * Product google.cloud.retail.v2beta.Product s sharing the same - * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY - * Product google.cloud.retail.v2beta.Product. For example: - * `primary_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2beta.Product s bundled in a - * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION - * Product google.cloud.retail.v2beta.Product. - * For example: - * `collection_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2beta.Product s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * If the specified - * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY - * Product google.cloud.retail.v2beta.Product or - * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION - * Product google.cloud.retail.v2beta.Product does not exist, a NOT_FOUND - * error is returned. - */ - // const filter = 'abc123' - /** - * The fields of Product google.cloud.retail.v2beta.Product to return in - * the responses. If not set or empty, the following fields are returned: - * * Product.name google.cloud.retail.v2beta.Product.name - * * Product.id google.cloud.retail.v2beta.Product.id - * * Product.title google.cloud.retail.v2beta.Product.title - * * Product.uri google.cloud.retail.v2beta.Product.uri - * * Product.images google.cloud.retail.v2beta.Product.images - * * Product.price_info google.cloud.retail.v2beta.Product.price_info - * * Product.brands google.cloud.retail.v2beta.Product.brands - * If "*" is provided, all fields are returned. - * Product.name google.cloud.retail.v2beta.Product.name is always returned - * no matter what mask is set. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const readMask = {} - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END retail_v2beta_generated_ProductService_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js deleted file mode 100644 index 3163edcb..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type, - * such as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * Product google.cloud.retail.v2beta.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveFulfillmentPlaces(); - // [END retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js deleted file mode 100644 index a61bac1d..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, placeIds) { - // [START retail_v2beta_generated_ProductService_RemoveLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - */ - // const placeIds = 'abc123' - /** - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * Product google.cloud.retail.v2beta.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveLocalInventories() { - // Construct request - const request = { - product, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveLocalInventories(); - // [END retail_v2beta_generated_ProductService_RemoveLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js deleted file mode 100644 index ac7ceeff..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js +++ /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 -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(inventory) { - // [START retail_v2beta_generated_ProductService_SetInventory_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The inventory information to update. The allowable fields to - * update are: - * * Product.price_info google.cloud.retail.v2beta.Product.price_info - * * Product.availability google.cloud.retail.v2beta.Product.availability - * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info - * The updated inventory fields must be specified in - * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask. - * If SetInventoryRequest.inventory.name is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2beta.Product named in - * Product.name google.cloud.retail.v2beta.Product.name, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2beta.Product to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * If the Product google.cloud.retail.v2beta.Product to update has existing - * inventory information, the provided inventory information will be merged - * while respecting the last update time for each inventory field, using the - * provided or default value for - * SetInventoryRequest.set_time google.cloud.retail.v2beta.SetInventoryRequest.set_time. - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in SetInventoryRequest.inventory.fulfillment_info - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types to clear in - * SetInventoryRequest.inventory.fulfillment_info - * * Checks that only the desired fulfillment info types have empty - * SetInventoryRequest.inventory.fulfillment_info.place_ids - * The last update time is recorded for the following inventory fields: - * * Product.price_info google.cloud.retail.v2beta.Product.price_info - * * Product.availability google.cloud.retail.v2beta.Product.availability - * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info - * If a full overwrite of inventory information while ignoring timestamps is - * needed, UpdateProduct should be invoked instead. - */ - // const inventory = {} - /** - * Indicates which inventory fields in the provided - * Product google.cloud.retail.v2beta.Product to update. - * At least one field must be provided. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const setMask = {} - /** - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - */ - // const setTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product with - * name Product.name google.cloud.retail.v2beta.Product.name is not found, - * the inventory update will still be processed and retained for at most 1 day - * until the Product google.cloud.retail.v2beta.Product is created. If set - * to false, a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callSetInventory() { - // Construct request - const request = { - inventory, - }; - - // Run request - const [operation] = await retailClient.setInventory(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInventory(); - // [END retail_v2beta_generated_ProductService_SetInventory_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js deleted file mode 100644 index ed319228..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START retail_v2beta_generated_ProductService_UpdateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The product to update/create. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2beta.Product to update does not - * exist and - * allow_missing google.cloud.retail.v2beta.UpdateProductRequest.allow_missing - * is not set, a NOT_FOUND error is returned. - */ - // const product = {} - /** - * Indicates which fields in the provided - * Product google.cloud.retail.v2beta.Product to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, a new Product google.cloud.retail.v2beta.Product will be - * created. In this situation, `update_mask` is ignored. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await retailClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END retail_v2beta_generated_ProductService_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js b/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js deleted file mode 100644 index 62f1df1e..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js +++ /dev/null @@ -1,261 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, visitorId) { - // [START retail_v2beta_generated_SearchService_Search_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - */ - // const placement = 'abc123' - /** - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - */ - // const branch = 'abc123' - /** - * Raw search query. - */ - // const query = 'abc123' - /** - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * This should be the same identifier as - * UserEvent.visitor_id google.cloud.retail.v2beta.UserEvent.visitor_id. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * User information. - */ - // const userInfo = {} - /** - * Maximum number of Product google.cloud.retail.v2beta.Product s to return. - * If unspecified, defaults to a reasonable value. The maximum allowed value - * is 120. Values above 120 will be coerced to 120. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * SearchResponse.next_page_token google.cloud.retail.v2beta.SearchResponse.next_page_token, - * received from a previous - * SearchService.Search google.cloud.retail.v2beta.SearchService.Search - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SearchService.Search google.cloud.retail.v2beta.SearchService.Search - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the Product google.cloud.retail.v2beta.Product s - * deemed by the API as relevant) in search results. This field is only - * considered if - * page_token google.cloud.retail.v2beta.SearchRequest.page_token is unset. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const offset = 1234 - /** - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const filter = 'abc123' - /** - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * SearchRequest.canonical_filter google.cloud.retail.v2beta.SearchRequest.canonical_filter - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * See SearchRequest.filter google.cloud.retail.v2beta.SearchRequest.filter - * for more details about filter syntax. - */ - // const canonicalFilter = 'abc123' - /** - * The order in which products are returned. Products can be ordered by - * a field in an Product google.cloud.retail.v2beta.Product object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#order). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const orderBy = 'abc123' - /** - * Facet specifications for faceted search. If empty, no facets are returned. - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - */ - // const facetSpecs = 1234 - /** - * Boost specification to boost certain products. See more details at this - * user guide (https://cloud.google.com/retail/docs/boosting). - * Notice that if both - * ServingConfig.boost_control_ids google.cloud.retail.v2beta.ServingConfig.boost_control_ids - * and SearchRequest.boost_spec are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - */ - // const boostSpec = {} - /** - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this user - * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). - */ - // const queryExpansionSpec = {} - /** - * The keys to fetch and rollup the matching - * variant google.cloud.retail.v2beta.Product.Type.VARIANT - * Product google.cloud.retail.v2beta.Product s attributes, - * FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo or - * LocalInventory google.cloud.retail.v2beta.LocalInventory s attributes. - * The attributes from all the matching - * variant google.cloud.retail.v2beta.Product.Type.VARIANT - * Product google.cloud.retail.v2beta.Product s or - * LocalInventory google.cloud.retail.v2beta.LocalInventory s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * For FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * Supported keys are: - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * Product.inventories.attributes map. - * * attributes.key, where key is any key in the - * Product.attributes google.cloud.retail.v2beta.Product.attributes map. - * * pickupInStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "pickup-in-store". - * * shipToStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-1". - * * customFulfillment2.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-2". - * * customFulfillment3.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-3". - * * customFulfillment4.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-4". - * * customFulfillment5.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-5". - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - */ - // const variantRollupKeys = 'abc123' - /** - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * UserEvent.page_categories google.cloud.retail.v2beta.UserEvent.page_categories; - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : "Sales > 2017 Black Friday Deals". - */ - // const pageCategories = 'abc123' - /** - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - */ - // const searchMode = {} - /** - * The specification for personalization. - */ - // const personalizationSpec = {} - - // Imports the Retail library - const {SearchServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new SearchServiceClient(); - - async function callSearch() { - // Construct request - const request = { - placement, - visitorId, - }; - - // Run request - const iterable = await retailClient.searchAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearch(); - // [END retail_v2beta_generated_SearchService_Search_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js deleted file mode 100644 index 9086bb91..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig, controlId) { - // [START retail_v2beta_generated_ServingConfigService_AddControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const servingConfig = 'abc123' - /** - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config - if id is not found a NOT_FOUND error is returned. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callAddControl() { - // Construct request - const request = { - servingConfig, - controlId, - }; - - // Run request - const response = await retailClient.addControl(request); - console.log(response); - } - - callAddControl(); - // [END retail_v2beta_generated_ServingConfigService_AddControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js deleted file mode 100644 index fc8ba733..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.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, servingConfig, servingConfigId) { - // [START retail_v2beta_generated_ServingConfigService_CreateServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of parent. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Required. The ServingConfig to create. - */ - // const servingConfig = {} - /** - * Required. The ID to use for the ServingConfig, which will become the final - * component of the ServingConfig's resource name. - * This value should be 4-63 characters, and valid characters - * are /[a-z][0-9]-_/. - */ - // const servingConfigId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callCreateServingConfig() { - // Construct request - const request = { - parent, - servingConfig, - servingConfigId, - }; - - // Run request - const response = await retailClient.createServingConfig(request); - console.log(response); - } - - callCreateServingConfig(); - // [END retail_v2beta_generated_ServingConfigService_CreateServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js deleted file mode 100644 index c9202725..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the ServingConfig to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callDeleteServingConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteServingConfig(request); - console.log(response); - } - - callDeleteServingConfig(); - // [END retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js deleted file mode 100644 index be98fd45..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ServingConfigService_GetServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the ServingConfig to get. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callGetServingConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getServingConfig(request); - console.log(response); - } - - callGetServingConfig(); - // [END retail_v2beta_generated_ServingConfigService_GetServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js deleted file mode 100644 index 7a517f3e..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.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 retail_v2beta_generated_ServingConfigService_ListServingConfigs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callListServingConfigs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listServingConfigsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServingConfigs(); - // [END retail_v2beta_generated_ServingConfigService_ListServingConfigs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js deleted file mode 100644 index 314b82f9..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig, controlId) { - // [START retail_v2beta_generated_ServingConfigService_RemoveControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const servingConfig = 'abc123' - /** - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callRemoveControl() { - // Construct request - const request = { - servingConfig, - controlId, - }; - - // Run request - const response = await retailClient.removeControl(request); - console.log(response); - } - - callRemoveControl(); - // [END retail_v2beta_generated_ServingConfigService_RemoveControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js deleted file mode 100644 index f948464a..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig) { - // [START retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ServingConfig to update. - */ - // const servingConfig = {} - /** - * Indicates which fields in the provided - * ServingConfig google.cloud.retail.v2beta.ServingConfig to update. The - * following are NOT supported: - * * ServingConfig.name google.cloud.retail.v2beta.ServingConfig.name - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callUpdateServingConfig() { - // Construct request - const request = { - servingConfig, - }; - - // Run request - const response = await retailClient.updateServingConfig(request); - console.log(response); - } - - callUpdateServingConfig(); - // [END retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json b/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json deleted file mode 100644 index 8e89b650..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json +++ /dev/null @@ -1,2131 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-retail", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.retail.v2beta", - "version": "v2beta" - } - ] - }, - "snippets": [ - { - "regionTag": "retail_v2beta_generated_CatalogService_ListCatalogs_async", - "title": "CatalogService listCatalogs Sample", - "origin": "API_DEFINITION", - "description": " Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated with the project.", - "canonical": true, - "file": "catalog_service.list_catalogs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ListCatalogsResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_UpdateCatalog_async", - "title": "CatalogService updateCatalog Sample", - "origin": "API_DEFINITION", - "description": " Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s.", - "canonical": true, - "file": "catalog_service.update_catalog.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": ".google.cloud.retail.v2beta.Catalog" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.Catalog", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_SetDefaultBranch_async", - "title": "CatalogService setDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", - "canonical": true, - "file": "catalog_service.set_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "branch_id", - "type": "TYPE_STRING" - }, - { - "name": "note", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_GetDefaultBranch_async", - "title": "CatalogService getDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] method under a specified parent catalog.", - "canonical": true, - "file": "catalog_service.get_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.GetDefaultBranchResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_GetCompletionConfig_async", - "title": "CatalogService getCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig].", - "canonical": true, - "file": "catalog_service.get_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async", - "title": "CatalogService updateCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s.", - "canonical": true, - "file": "catalog_service.update_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", - "async": true, - "parameters": [ - { - "name": "completion_config", - "type": ".google.cloud.retail.v2beta.CompletionConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_GetAttributesConfig_async", - "title": "CatalogService getAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig].", - "canonical": true, - "file": "catalog_service.get_attributes_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async", - "title": "CatalogService updateAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", - "canonical": true, - "file": "catalog_service.update_attributes_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": ".google.cloud.retail.v2beta.AttributesConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_AddCatalogAttribute_async", - "title": "CatalogService addCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", - "canonical": true, - "file": "catalog_service.add_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2beta.CatalogAttribute" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async", - "title": "CatalogService removeCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "catalog_service.remove_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "key", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async", - "title": "CatalogService replaceCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "catalog_service.replace_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2beta.CatalogAttribute" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CompletionService_CompleteQuery_async", - "title": "CatalogService completeQuery Sample", - "origin": "API_DEFINITION", - "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 109, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "language_codes", - "type": "TYPE_STRING[]" - }, - { - "name": "device_type", - "type": "TYPE_STRING" - }, - { - "name": "dataset", - "type": "TYPE_STRING" - }, - { - "name": "max_suggestions", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.retail.v2beta.CompleteQueryResponse", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" - }, - "method": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2beta.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CompletionService_ImportCompletionData_async", - "title": "CatalogService importCompletionData Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.import_completion_data.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2beta.CompletionDataInputConfig" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" - }, - "method": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2beta.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_CreateControl_async", - "title": "CatalogService createControl Sample", - "origin": "API_DEFINITION", - "description": " Creates a Control. If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an ALREADY_EXISTS error is returned.", - "canonical": true, - "file": "control_service.create_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "control", - "type": ".google.cloud.retail.v2beta.Control" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_DeleteControl_async", - "title": "CatalogService deleteControl Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Control. If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.delete_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_UpdateControl_async", - "title": "CatalogService updateControl Sample", - "origin": "API_DEFINITION", - "description": " Updates a Control. [Control][google.cloud.retail.v2beta.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.update_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", - "async": true, - "parameters": [ - { - "name": "control", - "type": ".google.cloud.retail.v2beta.Control" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_GetControl_async", - "title": "CatalogService getControl Sample", - "origin": "API_DEFINITION", - "description": " Gets a Control.", - "canonical": true, - "file": "control_service.get_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_ListControls_async", - "title": "CatalogService listControls Sample", - "origin": "API_DEFINITION", - "description": " Lists all Controls linked to this catalog.", - "canonical": true, - "file": "control_service.list_controls.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ListControlsResponse", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_PredictionService_Predict_async", - "title": "CatalogService predict Sample", - "origin": "API_DEFINITION", - "description": " Makes a recommendation prediction.", - "canonical": true, - "file": "prediction_service.predict.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 153, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2beta.UserEvent" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "params", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.retail.v2beta.PredictResponse", - "client": { - "shortName": "PredictionServiceClient", - "fullName": "google.cloud.retail.v2beta.PredictionServiceClient" - }, - "method": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", - "service": { - "shortName": "PredictionService", - "fullName": "google.cloud.retail.v2beta.PredictionService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_CreateProduct_async", - "title": "CatalogService createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Product][google.cloud.retail.v2beta.Product].", - "canonical": true, - "file": "product_service.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.retail.v2beta.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_GetProduct_async", - "title": "CatalogService getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Product][google.cloud.retail.v2beta.Product].", - "canonical": true, - "file": "product_service.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_ListProducts_async", - "title": "CatalogService listProducts Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Product][google.cloud.retail.v2beta.Product]s.", - "canonical": true, - "file": "product_service.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 124, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "read_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.ListProductsResponse", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_UpdateProduct_async", - "title": "CatalogService updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Product][google.cloud.retail.v2beta.Product].", - "canonical": true, - "file": "product_service.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.retail.v2beta.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.retail.v2beta.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_DeleteProduct_async", - "title": "CatalogService deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Product][google.cloud.retail.v2beta.Product].", - "canonical": true, - "file": "product_service.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_ImportProducts_async", - "title": "CatalogService importProducts Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2beta.Product]s to be successfully updated.", - "canonical": true, - "file": "product_service.import_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 85, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2beta.ProductInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "reconciliation_mode", - "type": ".google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_SetInventory_async", - "title": "CatalogService setInventory Sample", - "origin": "API_DEFINITION", - "description": " Updates inventory information for a [Product][google.cloud.retail.v2beta.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.set_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 116, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", - "async": true, - "parameters": [ - { - "name": "inventory", - "type": ".google.cloud.retail.v2beta.Product" - }, - { - "name": "set_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "set_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async", - "title": "CatalogService addFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 107, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async", - "title": "CatalogService removeFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 103, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_AddLocalInventories_async", - "title": "CatalogService addLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Updates local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 92, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "local_inventories", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "add_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_RemoveLocalInventories_async", - "title": "CatalogService removeLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Remove local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_SearchService_Search_async", - "title": "CatalogService search Sample", - "origin": "API_DEFINITION", - "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 253, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2beta.SearchService.Search", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "branch", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "user_info", - "type": ".google.cloud.retail.v2beta.UserInfo" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "offset", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "canonical_filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "facet_specs", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "dynamic_facet_spec", - "type": ".google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec" - }, - { - "name": "boost_spec", - "type": ".google.cloud.retail.v2beta.SearchRequest.BoostSpec" - }, - { - "name": "query_expansion_spec", - "type": ".google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec" - }, - { - "name": "variant_rollup_keys", - "type": "TYPE_STRING[]" - }, - { - "name": "page_categories", - "type": "TYPE_STRING[]" - }, - { - "name": "search_mode", - "type": ".google.cloud.retail.v2beta.SearchRequest.SearchMode" - }, - { - "name": "personalization_spec", - "type": ".google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec" - } - ], - "resultType": ".google.cloud.retail.v2beta.SearchResponse", - "client": { - "shortName": "SearchServiceClient", - "fullName": "google.cloud.retail.v2beta.SearchServiceClient" - }, - "method": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2beta.SearchService.Search", - "service": { - "shortName": "SearchService", - "fullName": "google.cloud.retail.v2beta.SearchService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_CreateServingConfig_async", - "title": "CatalogService createServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise a FAILED_PRECONDITION error is returned.", - "canonical": true, - "file": "serving_config_service.create_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "serving_config", - "type": ".google.cloud.retail.v2beta.ServingConfig" - }, - { - "name": "serving_config_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async", - "title": "CatalogService deleteServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", - "canonical": true, - "file": "serving_config_service.delete_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async", - "title": "CatalogService updateServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates a ServingConfig.", - "canonical": true, - "file": "serving_config_service.update_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": ".google.cloud.retail.v2beta.ServingConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_GetServingConfig_async", - "title": "CatalogService getServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", - "canonical": true, - "file": "serving_config_service.get_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_ListServingConfigs_async", - "title": "CatalogService listServingConfigs Sample", - "origin": "API_DEFINITION", - "description": " Lists all ServingConfigs linked to this catalog.", - "canonical": true, - "file": "serving_config_service.list_serving_configs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ListServingConfigsResponse", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_AddControl_async", - "title": "CatalogService addControl Sample", - "origin": "API_DEFINITION", - "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", - "canonical": true, - "file": "serving_config_service.add_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_RemoveControl_async", - "title": "CatalogService removeControl Sample", - "origin": "API_DEFINITION", - "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", - "canonical": true, - "file": "serving_config_service.remove_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_WriteUserEvent_async", - "title": "CatalogService writeUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event.", - "canonical": true, - "file": "user_event_service.write_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2beta.UserEvent" - } - ], - "resultType": ".google.cloud.retail.v2beta.UserEvent", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_CollectUserEvent_async", - "title": "CatalogService collectUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", - "canonical": true, - "file": "user_event_service.collect_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.api.HttpBody", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_PurgeUserEvents_async", - "title": "CatalogService purgeUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", - "canonical": true, - "file": "user_event_service.purge_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 83, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_ImportUserEvents_async", - "title": "CatalogService importUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", - "canonical": true, - "file": "user_event_service.import_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2beta.UserEventInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_RejoinUserEvents_async", - "title": "CatalogService rejoinUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", - "canonical": true, - "file": "user_event_service.rejoin_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event_rejoin_scope", - "type": ".google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js deleted file mode 100644 index 933ec59d..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2beta_generated_UserEventService_CollectUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - */ - // const userEvent = 'abc123' - /** - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - */ - // const uri = 'abc123' - /** - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - */ - // const ets = 1234 - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callCollectUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.collectUserEvent(request); - console.log(response); - } - - callCollectUserEvent(); - // [END retail_v2beta_generated_UserEventService_CollectUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js deleted file mode 100644 index 842e14dd..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2beta_generated_UserEventService_ImportUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. `projects/1234/locations/global/catalogs/default_catalog` - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - */ - // const errorsConfig = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callImportUserEvents() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportUserEvents(); - // [END retail_v2beta_generated_UserEventService_ImportUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js deleted file mode 100644 index 059d6944..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, filter) { - // [START retail_v2beta_generated_UserEventService_PurgeUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - */ - // const parent = 'abc123' - /** - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * * `eventType`: Double quoted - * UserEvent.event_type google.cloud.retail.v2beta.UserEvent.event_type - * string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * Examples: - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * The filtering fields are assumed to have an implicit AND. - */ - // const filter = 'abc123' - /** - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - */ - // const force = true - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callPurgeUserEvents() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await retailClient.purgeUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeUserEvents(); - // [END retail_v2beta_generated_UserEventService_PurgeUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js deleted file mode 100644 index aebf64dc..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2beta_generated_UserEventService_RejoinUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - */ - // const userEventRejoinScope = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callRejoinUserEvents() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await retailClient.rejoinUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRejoinUserEvents(); - // [END retail_v2beta_generated_UserEventService_RejoinUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js deleted file mode 100644 index da53a142..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2beta_generated_UserEventService_WriteUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callWriteUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.writeUserEvent(request); - console.log(response); - } - - callWriteUserEvent(); - // [END retail_v2beta_generated_UserEventService_WriteUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/src/index.ts b/owl-bot-staging/v2beta/src/index.ts deleted file mode 100644 index 4f42efab..00000000 --- a/owl-bot-staging/v2beta/src/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 v2beta from './v2beta'; -const CatalogServiceClient = v2beta.CatalogServiceClient; -type CatalogServiceClient = v2beta.CatalogServiceClient; -const CompletionServiceClient = v2beta.CompletionServiceClient; -type CompletionServiceClient = v2beta.CompletionServiceClient; -const ControlServiceClient = v2beta.ControlServiceClient; -type ControlServiceClient = v2beta.ControlServiceClient; -const PredictionServiceClient = v2beta.PredictionServiceClient; -type PredictionServiceClient = v2beta.PredictionServiceClient; -const ProductServiceClient = v2beta.ProductServiceClient; -type ProductServiceClient = v2beta.ProductServiceClient; -const SearchServiceClient = v2beta.SearchServiceClient; -type SearchServiceClient = v2beta.SearchServiceClient; -const ServingConfigServiceClient = v2beta.ServingConfigServiceClient; -type ServingConfigServiceClient = v2beta.ServingConfigServiceClient; -const UserEventServiceClient = v2beta.UserEventServiceClient; -type UserEventServiceClient = v2beta.UserEventServiceClient; -export {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -export default {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts deleted file mode 100644 index 7c74bd3f..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts +++ /dev/null @@ -1,1865 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/catalog_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './catalog_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for managing catalog configuration. - * @class - * @memberof v2beta - */ -export class CatalogServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - catalogServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CatalogServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CatalogServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listCatalogs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.CatalogService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.catalogServiceStub) { - return this.catalogServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.CatalogService. - this.catalogServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.CatalogService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.CatalogService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const catalogServiceStubMethods = - ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch', 'getCompletionConfig', 'updateCompletionConfig', 'getAttributesConfig', 'updateAttributesConfig', 'addCatalogAttribute', 'removeCatalogAttribute', 'replaceCatalogAttribute']; - for (const methodName of catalogServiceStubMethods) { - const callPromise = this.catalogServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.catalogServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Updates the {@link google.cloud.retail.v2beta.Catalog|Catalog}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.Catalog} request.catalog - * Required. The {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2beta.Catalog|Catalog}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.Catalog|Catalog} to update does not - * exist, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2beta.Catalog}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.update_catalog.js - * region_tag:retail_v2beta_generated_CatalogService_UpdateCatalog_async - */ - updateCatalog( - request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|undefined, {}|undefined - ]>; - updateCatalog( - request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog.name': request.catalog!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCatalog(request, options, callback); - } -/** - * Set a specified branch id as default branch. API methods such as - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search}, - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct}, - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * will treat requests using "default_branch" to the actual branch id set as - * default. - * - * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as - * default, setting - * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent - * to setting - * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/1`. - * - * Using multiple branches can be useful when developers would like - * to have a staging branch to test and verify for future usage. When it - * becomes ready, developers switch on the staging branch using this API while - * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` - * as {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} - * to route the traffic to this staging branch. - * - * CAUTION: If you have live predict/search traffic, switching the default - * branch could potentially cause outages if the ID space of the new branch is - * very different from the old one. - * - * More specifically: - * - * * PredictionService will only return product IDs from branch {newBranch}. - * * SearchService will only return product IDs from branch {newBranch} - * (if branch is not explicitly set). - * * UserEventService will only join events with products from branch - * {newBranch}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.branchId - * The final component of the resource name of a branch. - * - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * - * If there are no sufficient active products in the targeted branch and - * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.force|force} is not - * set, a FAILED_PRECONDITION error is returned. - * @param {string} request.note - * Some note on this request, this can be retrieved by - * {@link google.cloud.retail.v2beta.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} - * before next valid default branch set occurs. - * - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {boolean} request.force - * If set to true, it permits switching to a branch with - * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id|branch_id} - * even if it has no sufficient active products. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.set_default_branch.js - * region_tag:retail_v2beta_generated_CatalogService_SetDefaultBranch_async - */ - setDefaultBranch( - request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|undefined, {}|undefined - ]>; - setDefaultBranch( - request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.setDefaultBranch(request, options, callback); - } -/** - * Get which branch is currently default branch set by - * {@link google.cloud.retail.v2beta.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} - * method under a specified parent catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2beta.GetDefaultBranchResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.get_default_branch.js - * region_tag:retail_v2beta_generated_CatalogService_GetDefaultBranch_async - */ - getDefaultBranch( - request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|undefined, {}|undefined - ]>; - getDefaultBranch( - request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.getDefaultBranch(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full CompletionConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.get_completion_config.js - * region_tag:retail_v2beta_generated_CatalogService_GetCompletionConfig_async - */ - getCompletionConfig( - request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|undefined, {}|undefined - ]>; - getCompletionConfig( - request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getCompletionConfig(request, options, callback); - } -/** - * Updates the - * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.CompletionConfig} request.completionConfig - * Required. The - * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}, then a - * PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to - * update does not exist, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. - * The following are the only supported fields: - * - * * {@link google.cloud.retail.v2beta.CompletionConfig.matching_order|CompletionConfig.matching_order} - * * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} - * * {@link google.cloud.retail.v2beta.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} - * * {@link google.cloud.retail.v2beta.CompletionConfig.auto_learning|CompletionConfig.auto_learning} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.update_completion_config.js - * region_tag:retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async - */ - updateCompletionConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|undefined, {}|undefined - ]>; - updateCompletionConfig( - request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'completion_config.name': request.completionConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCompletionConfig(request, options, callback); - } -/** - * Gets an {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.get_attributes_config.js - * region_tag:retail_v2beta_generated_CatalogService_GetAttributesConfig_async - */ - getAttributesConfig( - request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|undefined, {}|undefined - ]>; - getAttributesConfig( - request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getAttributesConfig(request, options, callback); - } -/** - * Updates the - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * The catalog attributes in the request will be updated in the catalog, or - * inserted if they do not exist. Existing catalog attributes not included in - * the request will remain unchanged. Attributes that are assigned to - * products, but do not exist at the catalog level, are always included in the - * response. The product attribute is assigned default values for missing - * catalog attribute fields, e.g., searchable and dynamic facetable options. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.AttributesConfig} request.attributesConfig - * Required. The - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. - * The following is the only supported field: - * - * * {@link google.cloud.retail.v2beta.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.update_attributes_config.js - * region_tag:retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async - */ - updateAttributesConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|undefined, {}|undefined - ]>; - updateAttributesConfig( - request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config.name': request.attributesConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateAttributesConfig(request, options, callback); - } -/** - * Adds the specified - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to the - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to - * add already exists, an ALREADY_EXISTS error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute - * Required. The - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to add. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.add_catalog_attribute.js - * region_tag:retail_v2beta_generated_CatalogService_AddCatalogAttribute_async - */ - addCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|undefined, {}|undefined - ]>; - addCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.addCatalogAttribute(request, options, callback); - } -/** - * Removes the specified - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} from the - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to - * remove does not exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {string} request.key - * Required. The attribute name key of the - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to remove. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.remove_catalog_attribute.js - * region_tag:retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async - */ - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|undefined, {}|undefined - ]>; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.removeCatalogAttribute(request, options, callback); - } -/** - * Replaces the specified - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} in the - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} by updating - * the catalog attribute with the same - * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key}. - * - * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to - * replace does not exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute - * Required. The updated - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to update. - * The following are NOT supported: - * - * * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.replace_catalog_attribute.js - * region_tag:retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async - */ - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|undefined, {}|undefined - ]>; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.replaceCatalogAttribute(request, options, callback); - } - - /** - * Lists all the {@link google.cloud.retail.v2beta.Catalog|Catalog}s associated - * with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. - * If unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2beta.Catalog}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogs( - request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICatalog[], - protos.google.cloud.retail.v2beta.IListCatalogsRequest|null, - protos.google.cloud.retail.v2beta.IListCatalogsResponse - ]>; - listCatalogs( - request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListCatalogsRequest, - protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2beta.ICatalog>): void; - listCatalogs( - request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListCatalogsRequest, - protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2beta.ICatalog>): void; - listCatalogs( - request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.IListCatalogsRequest, - protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2beta.ICatalog>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.IListCatalogsRequest, - protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2beta.ICatalog>): - Promise<[ - protos.google.cloud.retail.v2beta.ICatalog[], - protos.google.cloud.retail.v2beta.IListCatalogsRequest|null, - protos.google.cloud.retail.v2beta.IListCatalogsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listCatalogs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. - * If unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2beta.Catalog} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogsStream( - request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.createStream( - this.innerApiCalls.listCatalogs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listCatalogs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. - * If unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Catalog]{@link google.cloud.retail.v2beta.Catalog}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.list_catalogs.js - * region_tag:retail_v2beta_generated_CatalogService_ListCatalogs_async - */ - listCatalogsAsync( - request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.asyncIterate( - this.innerApiCalls['listCatalogs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.catalogServiceStub && !this._terminated) { - return this.catalogServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json deleted file mode 100644 index cd2aebd1..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.CatalogService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListCatalogs": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCatalog": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "SetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetCompletionConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCompletionConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetAttributesConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateAttributesConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "AddCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "RemoveCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ReplaceCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts deleted file mode 100644 index 871a336d..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts +++ /dev/null @@ -1,936 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/completion_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './completion_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Auto-completion service for retail. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2beta - */ -export class CompletionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - completionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CompletionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CompletionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importCompletionDataResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportCompletionDataResponse') as gax.protobuf.Type; - const importCompletionDataMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importCompletionData: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importCompletionDataResponse.decode.bind(importCompletionDataResponse), - importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.CompletionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.completionServiceStub) { - return this.completionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.CompletionService. - this.completionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.CompletionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.CompletionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const completionServiceStubMethods = - ['completeQuery', 'importCompletionData']; - for (const methodName of completionServiceStubMethods) { - const callPromise = this.completionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.completionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Completes the specified prefix with keyword suggestions. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Required. Catalog for which the completion is performed. - * - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.query - * Required. The query used to generate suggestions. - * - * The maximum number of allowed characters is 255. - * @param {string} request.visitorId - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {string[]} request.languageCodes - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see [Tags for - * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - * @param {string} request.deviceType - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * - * Supported formats: - * - * * `UNKNOWN_DEVICE_TYPE` - * - * * `DESKTOP` - * - * * `MOBILE` - * - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - * @param {string} request.dataset - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * {@link google.cloud.retail.v2beta.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * - * Current supported values: - * - * * user-data - * - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - * @param {number} request.maxSuggestions - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value - * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. - * - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2beta.CompleteQueryResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/completion_service.complete_query.js - * region_tag:retail_v2beta_generated_CompletionService_CompleteQuery_async - */ - completeQuery( - request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|undefined, {}|undefined - ]>; - completeQuery( - request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.completeQuery(request, options, callback); - } - -/** - * Bulk import of processed completion dataset. - * - * Request processing is asynchronous. Partial updating is not supported. - * - * The operation is successfully finished only after the imported suggestions - * are indexed successfully and ready for serving. The process takes hours. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog which the suggestions dataset belongs to. - * - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2beta.CompletionDataInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/completion_service.import_completion_data.js - * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async - */ - importCompletionData( - request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importCompletionData( - request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importCompletionData(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importCompletionData()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/completion_service.import_completion_data.js - * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async - */ - async checkImportCompletionDataProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.completionServiceStub && !this._terminated) { - return this.completionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json deleted file mode 100644 index 1865fe66..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.CompletionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CompleteQuery": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ImportCompletionData": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts deleted file mode 100644 index 297b302a..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts +++ /dev/null @@ -1,1195 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/control_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './control_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for modifying Control. - * @class - * @memberof v2beta - */ -export class ControlServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - controlServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ControlServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ControlServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listControls: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'controls') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.ControlService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.controlServiceStub) { - return this.controlServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.ControlService. - this.controlServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ControlService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.ControlService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const controlServiceStubMethods = - ['createControl', 'deleteControl', 'updateControl', 'getControl', 'listControls']; - for (const methodName of controlServiceStubMethods) { - const callPromise = this.controlServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.controlServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a Control. - * - * If the {@link google.cloud.retail.v2beta.Control|Control} to create already - * exists, an ALREADY_EXISTS error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full resource name of parent catalog. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {google.cloud.retail.v2beta.Control} request.control - * Required. The Control to create. - * @param {string} request.controlId - * Required. The ID to use for the Control, which will become the final - * component of the Control's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link 0-9|a-z}-_/. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.create_control.js - * region_tag:retail_v2beta_generated_ControlService_CreateControl_async - */ - createControl( - request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|undefined, {}|undefined - ]>; - createControl( - request: protos.google.cloud.retail.v2beta.ICreateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request: protos.google.cloud.retail.v2beta.ICreateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createControl(request, options, callback); - } -/** - * Deletes a Control. - * - * If the {@link google.cloud.retail.v2beta.Control|Control} to delete does not - * exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.delete_control.js - * region_tag:retail_v2beta_generated_ControlService_DeleteControl_async - */ - deleteControl( - request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|undefined, {}|undefined - ]>; - deleteControl( - request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteControl(request, options, callback); - } -/** - * Updates a Control. - * - * {@link google.cloud.retail.v2beta.Control|Control} cannot be set to a different - * oneof field, if so an INVALID_ARGUMENT is returned. If the - * {@link google.cloud.retail.v2beta.Control|Control} to delete does not exist, a - * NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.Control} request.control - * Required. The Control to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.Control|Control} to update. The following are - * NOT supported: - * - * * {@link google.cloud.retail.v2beta.Control.name|Control.name} - * - * If not set or empty, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.update_control.js - * region_tag:retail_v2beta_generated_ControlService_UpdateControl_async - */ - updateControl( - request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|undefined, {}|undefined - ]>; - updateControl( - request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'control.name': request.control!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateControl(request, options, callback); - } -/** - * Gets a Control. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.get_control.js - * region_tag:retail_v2beta_generated_ControlService_GetControl_async - */ - getControl( - request?: protos.google.cloud.retail.v2beta.IGetControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|undefined, {}|undefined - ]>; - getControl( - request: protos.google.cloud.retail.v2beta.IGetControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request: protos.google.cloud.retail.v2beta.IGetControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request?: protos.google.cloud.retail.v2beta.IGetControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getControl(request, options, callback); - } - - /** - * Lists all Controls linked to this catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Control]{@link google.cloud.retail.v2beta.Control}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listControlsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listControls( - request?: protos.google.cloud.retail.v2beta.IListControlsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IControl[], - protos.google.cloud.retail.v2beta.IListControlsRequest|null, - protos.google.cloud.retail.v2beta.IListControlsResponse - ]>; - listControls( - request: protos.google.cloud.retail.v2beta.IListControlsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListControlsRequest, - protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IControl>): void; - listControls( - request: protos.google.cloud.retail.v2beta.IListControlsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListControlsRequest, - protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IControl>): void; - listControls( - request?: protos.google.cloud.retail.v2beta.IListControlsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.IListControlsRequest, - protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IControl>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.IListControlsRequest, - protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IControl>): - Promise<[ - protos.google.cloud.retail.v2beta.IControl[], - protos.google.cloud.retail.v2beta.IListControlsRequest|null, - protos.google.cloud.retail.v2beta.IListControlsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listControls(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Control]{@link google.cloud.retail.v2beta.Control} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listControlsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listControlsStream( - request?: protos.google.cloud.retail.v2beta.IListControlsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listControls']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listControls.createStream( - this.innerApiCalls.listControls as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listControls`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Control]{@link google.cloud.retail.v2beta.Control}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.list_controls.js - * region_tag:retail_v2beta_generated_ControlService_ListControls_async - */ - listControlsAsync( - request?: protos.google.cloud.retail.v2beta.IListControlsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listControls']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listControls.asyncIterate( - this.innerApiCalls['listControls'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.controlServiceStub && !this._terminated) { - return this.controlServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json deleted file mode 100644 index b7572aeb..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.ControlService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListControls": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json b/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json deleted file mode 100644 index f9c6514c..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json +++ /dev/null @@ -1,571 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.retail.v2beta", - "libraryPackage": "@google-cloud/retail", - "services": { - "CatalogService": { - "clients": { - "grpc": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "GetCompletionConfig": { - "methods": [ - "getCompletionConfig" - ] - }, - "UpdateCompletionConfig": { - "methods": [ - "updateCompletionConfig" - ] - }, - "GetAttributesConfig": { - "methods": [ - "getAttributesConfig" - ] - }, - "UpdateAttributesConfig": { - "methods": [ - "updateAttributesConfig" - ] - }, - "AddCatalogAttribute": { - "methods": [ - "addCatalogAttribute" - ] - }, - "RemoveCatalogAttribute": { - "methods": [ - "removeCatalogAttribute" - ] - }, - "ReplaceCatalogAttribute": { - "methods": [ - "replaceCatalogAttribute" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "GetCompletionConfig": { - "methods": [ - "getCompletionConfig" - ] - }, - "UpdateCompletionConfig": { - "methods": [ - "updateCompletionConfig" - ] - }, - "GetAttributesConfig": { - "methods": [ - "getAttributesConfig" - ] - }, - "UpdateAttributesConfig": { - "methods": [ - "updateAttributesConfig" - ] - }, - "AddCatalogAttribute": { - "methods": [ - "addCatalogAttribute" - ] - }, - "RemoveCatalogAttribute": { - "methods": [ - "removeCatalogAttribute" - ] - }, - "ReplaceCatalogAttribute": { - "methods": [ - "replaceCatalogAttribute" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - } - } - }, - "CompletionService": { - "clients": { - "grpc": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - } - } - }, - "ControlService": { - "clients": { - "grpc": { - "libraryClient": "ControlServiceClient", - "rpcs": { - "CreateControl": { - "methods": [ - "createControl" - ] - }, - "DeleteControl": { - "methods": [ - "deleteControl" - ] - }, - "UpdateControl": { - "methods": [ - "updateControl" - ] - }, - "GetControl": { - "methods": [ - "getControl" - ] - }, - "ListControls": { - "methods": [ - "listControls", - "listControlsStream", - "listControlsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ControlServiceClient", - "rpcs": { - "CreateControl": { - "methods": [ - "createControl" - ] - }, - "DeleteControl": { - "methods": [ - "deleteControl" - ] - }, - "UpdateControl": { - "methods": [ - "updateControl" - ] - }, - "GetControl": { - "methods": [ - "getControl" - ] - }, - "ListControls": { - "methods": [ - "listControls", - "listControlsStream", - "listControlsAsync" - ] - } - } - } - } - }, - "PredictionService": { - "clients": { - "grpc": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - } - } - }, - "ProductService": { - "clients": { - "grpc": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - } - } - }, - "SearchService": { - "clients": { - "grpc": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - } - } - }, - "ServingConfigService": { - "clients": { - "grpc": { - "libraryClient": "ServingConfigServiceClient", - "rpcs": { - "CreateServingConfig": { - "methods": [ - "createServingConfig" - ] - }, - "DeleteServingConfig": { - "methods": [ - "deleteServingConfig" - ] - }, - "UpdateServingConfig": { - "methods": [ - "updateServingConfig" - ] - }, - "GetServingConfig": { - "methods": [ - "getServingConfig" - ] - }, - "AddControl": { - "methods": [ - "addControl" - ] - }, - "RemoveControl": { - "methods": [ - "removeControl" - ] - }, - "ListServingConfigs": { - "methods": [ - "listServingConfigs", - "listServingConfigsStream", - "listServingConfigsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ServingConfigServiceClient", - "rpcs": { - "CreateServingConfig": { - "methods": [ - "createServingConfig" - ] - }, - "DeleteServingConfig": { - "methods": [ - "deleteServingConfig" - ] - }, - "UpdateServingConfig": { - "methods": [ - "updateServingConfig" - ] - }, - "GetServingConfig": { - "methods": [ - "getServingConfig" - ] - }, - "AddControl": { - "methods": [ - "addControl" - ] - }, - "RemoveControl": { - "methods": [ - "removeControl" - ] - }, - "ListServingConfigs": { - "methods": [ - "listServingConfigs", - "listServingConfigsStream", - "listServingConfigsAsync" - ] - } - } - } - } - }, - "UserEventService": { - "clients": { - "grpc": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/index.ts b/owl-bot-staging/v2beta/src/v2beta/index.ts deleted file mode 100644 index a7e4f6ba..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {CatalogServiceClient} from './catalog_service_client'; -export {CompletionServiceClient} from './completion_service_client'; -export {ControlServiceClient} from './control_service_client'; -export {PredictionServiceClient} from './prediction_service_client'; -export {ProductServiceClient} from './product_service_client'; -export {SearchServiceClient} from './search_service_client'; -export {ServingConfigServiceClient} from './serving_config_service_client'; -export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts deleted file mode 100644 index 7f5f710e..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts +++ /dev/null @@ -1,837 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/prediction_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './prediction_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for making recommendation prediction. - * @class - * @memberof v2beta - */ -export class PredictionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - predictionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PredictionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PredictionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.PredictionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.predictionServiceStub) { - return this.predictionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.PredictionService. - this.predictionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.PredictionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.PredictionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const predictionServiceStubMethods = - ['predict']; - for (const methodName of predictionServiceStubMethods) { - const callPromise = this.predictionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.predictionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Makes a recommendation prediction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see [Managing - * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - * @param {number} request.pageSize - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - * @param {string} request.pageToken - * The previous PredictResponse.next_page_token. - * @param {string} request.filter - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * - * Examples: - * - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - * @param {boolean} request.validateOnly - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - * @param {number[]} request.params - * Additional domain specific parameters for the predictions. - * - * Allowed values: - * - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - * @param {number[]} request.labels - * The labels applied to a resource must meet the following requirements: - * - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * - * See [Google Cloud - * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2beta.PredictResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/prediction_service.predict.js - * region_tag:retail_v2beta_generated_PredictionService_Predict_async - */ - predict( - request?: protos.google.cloud.retail.v2beta.IPredictRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|undefined, {}|undefined - ]>; - predict( - request: protos.google.cloud.retail.v2beta.IPredictRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request: protos.google.cloud.retail.v2beta.IPredictRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request?: protos.google.cloud.retail.v2beta.IPredictRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.predict(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.predictionServiceStub && !this._terminated) { - return this.predictionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json deleted file mode 100644 index ab64c45e..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.PredictionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Predict": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts deleted file mode 100644 index 284f15d5..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts +++ /dev/null @@ -1,2455 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/product_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting {@link google.cloud.retail.v2beta.Product|Product} - * information of the customer's website. - * @class - * @memberof v2beta - */ -export class ProductServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ProductServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importProductsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportProductsResponse') as gax.protobuf.Type; - const importProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; - const setInventoryResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.SetInventoryResponse') as gax.protobuf.Type; - const setInventoryMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.SetInventoryMetadata') as gax.protobuf.Type; - const addFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse') as gax.protobuf.Type; - const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; - const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; - const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; - const addLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.AddLocalInventoriesResponse') as gax.protobuf.Type; - const addLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.AddLocalInventoriesMetadata') as gax.protobuf.Type; - const removeLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse') as gax.protobuf.Type; - const removeLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductsResponse.decode.bind(importProductsResponse), - importProductsMetadata.decode.bind(importProductsMetadata)), - setInventory: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInventoryResponse.decode.bind(setInventoryResponse), - setInventoryMetadata.decode.bind(setInventoryMetadata)), - addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), - addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), - removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), - removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), - addLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), - addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), - removeLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), - removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.ProductService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.productServiceStub) { - return this.productServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.ProductService. - this.productServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ProductService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.ProductService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const productServiceStubMethods = - ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; - for (const methodName of productServiceStubMethods) { - const callPromise = this.productServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.productServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a {@link google.cloud.retail.v2beta.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - * @param {google.cloud.retail.v2beta.Product} request.product - * Required. The {@link google.cloud.retail.v2beta.Product|Product} to create. - * @param {string} request.productId - * Required. The ID to use for the - * {@link google.cloud.retail.v2beta.Product|Product}, which will become the final - * component of the {@link google.cloud.retail.v2beta.Product.name|Product.name}. - * - * If the caller does not have permission to create the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * This field must be unique among all - * {@link google.cloud.retail.v2beta.Product|Product}s with the same - * {@link google.cloud.retail.v2beta.CreateProductRequest.parent|parent}. - * Otherwise, an ALREADY_EXISTS error is returned. - * - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.create_product.js - * region_tag:retail_v2beta_generated_ProductService_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.retail.v2beta.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.retail.v2beta.ICreateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2beta.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the requested {@link google.cloud.retail.v2beta.Product|Product} does not - * exist, a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.get_product.js - * region_tag:retail_v2beta_generated_ProductService_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.retail.v2beta.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.retail.v2beta.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.retail.v2beta.IGetProductRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.retail.v2beta.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Updates a {@link google.cloud.retail.v2beta.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.Product} request.product - * Required. The product to update/create. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not - * exist and - * {@link google.cloud.retail.v2beta.UpdateProductRequest.allow_missing|allow_missing} - * is not set, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.Product|Product} to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, a new {@link google.cloud.retail.v2beta.Product|Product} will be - * created. In this situation, `update_mask` is ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.update_product.js - * region_tag:retail_v2beta_generated_ProductService_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Deletes a {@link google.cloud.retail.v2beta.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to delete the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.Product|Product} to delete does not - * exist, a NOT_FOUND error is returned. - * - * The {@link google.cloud.retail.v2beta.Product|Product} to delete can neither be - * a - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product} member nor a - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product} with more than one - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variants}. Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * All inventory information for the named - * {@link google.cloud.retail.v2beta.Product|Product} will be deleted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.delete_product.js - * region_tag:retail_v2beta_generated_ProductService_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } - -/** - * Bulk import of multiple {@link google.cloud.retail.v2beta.Product|Product}s. - * - * Request processing may be synchronous. No partial updating is supported. - * Non-existing items are created. - * - * Note that it is possible for a subset of the - * {@link google.cloud.retail.v2beta.Product|Product}s to be successfully updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - * @param {string} request.requestId - * Deprecated. This field has no effect. - * @param {google.cloud.retail.v2beta.ProductInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - * @param {google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode} request.reconciliationMode - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * {@link google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * - * Only supported when - * {@link google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} - * is set to `FULL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.import_products.js - * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async - */ - importProducts( - request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProducts( - request: protos.google.cloud.retail.v2beta.IImportProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request: protos.google.cloud.retail.v2beta.IImportProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.import_products.js - * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async - */ - async checkImportProductsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates inventory information for a - * {@link google.cloud.retail.v2beta.Product|Product} while respecting the last - * update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, updates are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * When inventory is updated with - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct}, - * the specified inventory field value(s) will overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update time for the specified inventory fields will be overwritten to the - * time of the - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} or - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} - * request. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2beta.CreateProductRequest.product|CreateProductRequest.product}, - * then any pre-existing inventory information for this product will be used. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, - * then any existing inventory information will be preserved. - * - * Pre-existing inventory information can only be updated with - * {@link google.cloud.retail.v2beta.ProductService.SetInventory|SetInventory}, - * {@link google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, - * and - * {@link google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.Product} request.inventory - * Required. The inventory information to update. The allowable fields to - * update are: - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} - * The updated inventory fields must be specified in - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. - * - * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2beta.Product|Product} named in - * {@link google.cloud.retail.v2beta.Product.name|Product.name}, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * - * If the {@link google.cloud.retail.v2beta.Product|Product} to update has existing - * inventory information, the provided inventory information will be merged - * while respecting the last update time for each inventory field, using the - * provided or default value for - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. - * - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} - * - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types to clear in - * {@link |SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} - * - * The last update time is recorded for the following inventory fields: - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} - * - * If a full overwrite of inventory information while ignoring timestamps is - * needed, {@link |UpdateProduct} should be invoked instead. - * @param {google.protobuf.FieldMask} request.setMask - * Indicates which inventory fields in the provided - * {@link google.cloud.retail.v2beta.Product|Product} to update. - * - * At least one field must be provided. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.setTime - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} with - * name {@link google.cloud.retail.v2beta.Product.name|Product.name} is not found, - * the inventory update will still be processed and retained for at most 1 day - * until the {@link google.cloud.retail.v2beta.Product|Product} is created. If set - * to false, a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.set_inventory.js - * region_tag:retail_v2beta_generated_ProductService_SetInventory_async - */ - setInventory( - request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInventory( - request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'inventory.name': request.inventory!.name || '', - }); - this.initialize(); - return this.innerApiCalls.setInventory(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInventory()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.set_inventory.js - * region_tag:retail_v2beta_generated_ProductService_SetInventory_async - */ - async checkSetInventoryProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally adds place IDs to - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the added place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}, such - * as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}. - * Duplicate IDs will be automatically ignored. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * If the total number of place IDs exceeds 2000 for this - * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type} after - * adding, then the update will be rejected. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js - * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async - */ - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js - * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async - */ - async checkAddFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally removes place IDs from a - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the removed place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}, - * such as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js - * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async - */ - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js - * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async - */ - async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates local inventory information for a - * {@link google.cloud.retail.v2beta.Product|Product} at a list of places, while - * respecting the last update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating - * inventory information. If the request is valid, the update will be enqueued - * and processed downstream. As a consequence, when a response is returned, - * updates are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} - * has no effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * @param {number[]} request.localInventories - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - * @param {google.protobuf.FieldMask} request.addMask - * Indicates which inventory fields in the provided list of - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory} to update. The - * field is updated to the provided value. - * - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, the local inventory will still be processed and retained for at - * most 1 day and processed once the - * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.add_local_inventories.js - * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async - */ - addLocalInventories( - request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addLocalInventories( - request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.add_local_inventories.js - * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async - */ - async checkAddLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Remove local inventory information for a - * {@link google.cloud.retail.v2beta.Product|Product} at a list of places at a - * removal timestamp. - * - * This process is asynchronous. If the request is valid, the removal will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, removals are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} - * has no effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * @param {string[]} request.placeIds - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js - * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async - */ - removeLocalInventories( - request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeLocalInventories( - request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js - * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async - */ - async checkRemoveLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.retail.v2beta.Product|Product}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product} or - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2beta.Product.name|Product.name} - * * {@link google.cloud.retail.v2beta.Product.id|Product.id} - * * {@link google.cloud.retail.v2beta.Product.title|Product.title} - * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2beta.Product.images|Product.images} - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.retail.v2beta.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.retail.v2beta.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct[], - protos.google.cloud.retail.v2beta.IListProductsRequest|null, - protos.google.cloud.retail.v2beta.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.retail.v2beta.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListProductsRequest, - protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IProduct>): void; - listProducts( - request: protos.google.cloud.retail.v2beta.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListProductsRequest, - protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IProduct>): void; - listProducts( - request?: protos.google.cloud.retail.v2beta.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.IListProductsRequest, - protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.IListProductsRequest, - protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IProduct>): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct[], - protos.google.cloud.retail.v2beta.IListProductsRequest|null, - protos.google.cloud.retail.v2beta.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product} or - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2beta.Product.name|Product.name} - * * {@link google.cloud.retail.v2beta.Product.id|Product.id} - * * {@link google.cloud.retail.v2beta.Product.title|Product.title} - * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2beta.Product.images|Product.images} - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2beta.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.retail.v2beta.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product} or - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2beta.Product.name|Product.name} - * * {@link google.cloud.retail.v2beta.Product.id|Product.id} - * * {@link google.cloud.retail.v2beta.Product.title|Product.title} - * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2beta.Product.images|Product.images} - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.retail.v2beta.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.list_products.js - * region_tag:retail_v2beta_generated_ProductService_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.retail.v2beta.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.productServiceStub && !this._terminated) { - return this.productServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json deleted file mode 100644 index 459b579d..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.ProductService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "GetProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ListProducts": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "UpdateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "DeleteProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportProducts": { - "timeout_millis": 300000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "SetInventory": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts deleted file mode 100644 index d3d87c33..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts +++ /dev/null @@ -1,1480 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/search_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './search_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2beta - */ -export class SearchServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - searchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SearchServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SearchServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - search: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.SearchService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.searchServiceStub) { - return this.searchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.SearchService. - this.searchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.SearchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.SearchService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const searchServiceStubMethods = - ['search']; - for (const methodName of searchServiceStubMethods) { - const callPromise = this.searchServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.searchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Performs a search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to a reasonable value. The maximum allowed value - * is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if - * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s attributes, - * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - search( - request?: protos.google.cloud.retail.v2beta.ISearchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2beta.ISearchRequest|null, - protos.google.cloud.retail.v2beta.ISearchResponse - ]>; - search( - request: protos.google.cloud.retail.v2beta.ISearchRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.ISearchRequest, - protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): void; - search( - request: protos.google.cloud.retail.v2beta.ISearchRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.ISearchRequest, - protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): void; - search( - request?: protos.google.cloud.retail.v2beta.ISearchRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.ISearchRequest, - protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.ISearchRequest, - protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): - Promise<[ - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2beta.ISearchRequest|null, - protos.google.cloud.retail.v2beta.ISearchResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.search(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to a reasonable value. The maximum allowed value - * is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if - * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s attributes, - * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - searchStream( - request?: protos.google.cloud.retail.v2beta.ISearchRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.createStream( - this.innerApiCalls.search as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `search`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to a reasonable value. The maximum allowed value - * is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if - * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s attributes, - * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/search_service.search.js - * region_tag:retail_v2beta_generated_SearchService_Search_async - */ - searchAsync( - request?: protos.google.cloud.retail.v2beta.ISearchRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.asyncIterate( - this.innerApiCalls['search'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.searchServiceStub && !this._terminated) { - return this.searchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json deleted file mode 100644 index 82de0f81..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.SearchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Search": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts deleted file mode 100644 index 9f807827..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts +++ /dev/null @@ -1,1333 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/serving_config_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './serving_config_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for modifying ServingConfig. - * @class - * @memberof v2beta - */ -export class ServingConfigServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - servingConfigServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ServingConfigServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ServingConfigServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listServingConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'servingConfigs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.ServingConfigService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.servingConfigServiceStub) { - return this.servingConfigServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.ServingConfigService. - this.servingConfigServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ServingConfigService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.ServingConfigService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const servingConfigServiceStubMethods = - ['createServingConfig', 'deleteServingConfig', 'updateServingConfig', 'getServingConfig', 'listServingConfigs', 'addControl', 'removeControl']; - for (const methodName of servingConfigServiceStubMethods) { - const callPromise = this.servingConfigServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.servingConfigServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a ServingConfig. - * - * A maximum of 100 {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig}s - * are allowed in a {@link google.cloud.retail.v2beta.Catalog|Catalog}, otherwise - * a FAILED_PRECONDITION error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full resource name of parent. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig - * Required. The ServingConfig to create. - * @param {string} request.servingConfigId - * Required. The ID to use for the ServingConfig, which will become the final - * component of the ServingConfig's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link 0-9|a-z}-_/. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.create_serving_config.js - * region_tag:retail_v2beta_generated_ServingConfigService_CreateServingConfig_async - */ - createServingConfig( - request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|undefined, {}|undefined - ]>; - createServingConfig( - request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createServingConfig(request, options, callback); - } -/** - * Deletes a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ServingConfig to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.delete_serving_config.js - * region_tag:retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async - */ - deleteServingConfig( - request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|undefined, {}|undefined - ]>; - deleteServingConfig( - request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteServingConfig(request, options, callback); - } -/** - * Updates a ServingConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig - * Required. The ServingConfig to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig} to update. The - * following are NOT supported: - * - * * {@link google.cloud.retail.v2beta.ServingConfig.name|ServingConfig.name} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.update_serving_config.js - * region_tag:retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async - */ - updateServingConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|undefined, {}|undefined - ]>; - updateServingConfig( - request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config.name': request.servingConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateServingConfig(request, options, callback); - } -/** - * Gets a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ServingConfig to get. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.get_serving_config.js - * region_tag:retail_v2beta_generated_ServingConfigService_GetServingConfig_async - */ - getServingConfig( - request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|undefined, {}|undefined - ]>; - getServingConfig( - request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getServingConfig(request, options, callback); - } -/** - * Enables a Control on the specified ServingConfig. - * The control is added in the last position of the list of controls - * it belongs to (e.g. if it's a facet spec control it will be applied - * in the last position of servingConfig.facetSpecIds) - * Returns a ALREADY_EXISTS error if the control has already been applied. - * Returns a FAILED_PRECONDITION error if the addition could exceed maximum - * number of control allowed for that type of control. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {string} request.controlId - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config - if id is not found a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.add_control.js - * region_tag:retail_v2beta_generated_ServingConfigService_AddControl_async - */ - addControl( - request?: protos.google.cloud.retail.v2beta.IAddControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|undefined, {}|undefined - ]>; - addControl( - request: protos.google.cloud.retail.v2beta.IAddControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request: protos.google.cloud.retail.v2beta.IAddControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request?: protos.google.cloud.retail.v2beta.IAddControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config': request.servingConfig || '', - }); - this.initialize(); - return this.innerApiCalls.addControl(request, options, callback); - } -/** - * Disables a Control on the specified ServingConfig. - * The control is removed from the ServingConfig. - * Returns a NOT_FOUND error if the Control is not enabled for the - * ServingConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {string} request.controlId - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.remove_control.js - * region_tag:retail_v2beta_generated_ServingConfigService_RemoveControl_async - */ - removeControl( - request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|undefined, {}|undefined - ]>; - removeControl( - request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config': request.servingConfig || '', - }); - this.initialize(); - return this.innerApiCalls.removeControl(request, options, callback); - } - - /** - * Lists all ServingConfigs linked to this catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServingConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listServingConfigs( - request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig[], - protos.google.cloud.retail.v2beta.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse - ]>; - listServingConfigs( - request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IServingConfig>): void; - listServingConfigs( - request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IServingConfig>): void; - listServingConfigs( - request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IServingConfig>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IServingConfig>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig[], - protos.google.cloud.retail.v2beta.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listServingConfigs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServingConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listServingConfigsStream( - request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listServingConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServingConfigs.createStream( - this.innerApiCalls.listServingConfigs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServingConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.list_serving_configs.js - * region_tag:retail_v2beta_generated_ServingConfigService_ListServingConfigs_async - */ - listServingConfigsAsync( - request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listServingConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServingConfigs.asyncIterate( - this.innerApiCalls['listServingConfigs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.servingConfigServiceStub && !this._terminated) { - return this.servingConfigServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json deleted file mode 100644 index 2d17b527..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.ServingConfigService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListServingConfigs": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AddControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts deleted file mode 100644 index 86906d7b..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts +++ /dev/null @@ -1,1201 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/user_event_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './user_event_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting end user actions on the customer website. - * @class - * @memberof v2beta - */ -export class UserEventServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - userEventServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of UserEventServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof UserEventServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const purgeUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.PurgeUserEventsResponse') as gax.protobuf.Type; - const purgeUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.PurgeMetadata') as gax.protobuf.Type; - const importUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportUserEventsResponse') as gax.protobuf.Type; - const importUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; - const rejoinUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RejoinUserEventsResponse') as gax.protobuf.Type; - const rejoinUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RejoinUserEventsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - purgeUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), - purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), - importUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importUserEventsResponse.decode.bind(importUserEventsResponse), - importUserEventsMetadata.decode.bind(importUserEventsMetadata)), - rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), - rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.UserEventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.userEventServiceStub) { - return this.userEventServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.UserEventService. - this.userEventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.UserEventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.UserEventService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const userEventServiceStubMethods = - ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; - for (const methodName of userEventServiceStubMethods) { - const callPromise = this.userEventServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.userEventServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Writes a single user event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent - * Required. User event to write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2beta.UserEvent}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.write_user_event.js - * region_tag:retail_v2beta_generated_UserEventService_WriteUserEvent_async - */ - writeUserEvent( - request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|undefined, {}|undefined - ]>; - writeUserEvent( - request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.writeUserEvent(request, options, callback); - } -/** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Retail API JavaScript pixel and Google Tag - * Manager. Users should not call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {string} request.userEvent - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - * @param {string} request.uri - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - * @param {number} request.ets - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.collect_user_event.js - * region_tag:retail_v2beta_generated_UserEventService_CollectUserEvent_async - */ - collectUserEvent( - request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|undefined, {}|undefined - ]>; - collectUserEvent( - request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.collectUserEvent(request, options, callback); - } - -/** - * Deletes permanently all user events specified by the filter provided. - * Depending on the number of events specified by the filter, this operation - * could take hours or days to complete. To test a filter, use the list - * command first. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - * @param {string} request.filter - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * - * * `eventType`: Double quoted - * {@link google.cloud.retail.v2beta.UserEvent.event_type|UserEvent.event_type} - * string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * - * Examples: - * - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * - * The filtering fields are assumed to have an implicit AND. - * @param {boolean} request.force - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async - */ - purgeUserEvents( - request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeUserEvents( - request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.purgeUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async - */ - async checkPurgeUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. `projects/1234/locations/global/catalogs/default_catalog` - * @param {google.cloud.retail.v2beta.UserEventInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.import_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async - */ - importUserEvents( - request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importUserEvents( - request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.import_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async - */ - async checkImportUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a user event rejoin operation with latest product catalog. Events - * will not be annotated with detailed product information if product is - * missing from the catalog at the time the user event is ingested, and these - * events are stored as unjoined events with a limited usage on training and - * serving. This method can be used to start a join operation on specified - * events with latest version of product catalog. It can also be used to - * correct events joined with the wrong product catalog. A rejoin operation - * can take hours or days to complete. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async - */ - rejoinUserEvents( - request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rejoinUserEvents( - request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.rejoinUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rejoinUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async - */ - async checkRejoinUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.userEventServiceStub && !this._terminated) { - return this.userEventServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json deleted file mode 100644 index f5bd2bae..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.UserEventService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "WriteUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "CollectUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "PurgeUserEvents": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportUserEvents": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "RejoinUserEvents": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 57b7c7be..00000000 --- a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const retail = require('@google-cloud/retail'); - -function main() { - const catalogServiceClient = new retail.CatalogServiceClient(); - const completionServiceClient = new retail.CompletionServiceClient(); - const controlServiceClient = new retail.ControlServiceClient(); - const predictionServiceClient = new retail.PredictionServiceClient(); - const productServiceClient = new retail.ProductServiceClient(); - const searchServiceClient = new retail.SearchServiceClient(); - const servingConfigServiceClient = new retail.ServingConfigServiceClient(); - const userEventServiceClient = new retail.UserEventServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 25eaae42..00000000 --- a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts +++ /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. ** - -import {CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient} from '@google-cloud/retail'; - -// check that the client class type name can be used -function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { - client.close(); -} -function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { - client.close(); -} -function doStuffWithControlServiceClient(client: ControlServiceClient) { - client.close(); -} -function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { - client.close(); -} -function doStuffWithProductServiceClient(client: ProductServiceClient) { - client.close(); -} -function doStuffWithSearchServiceClient(client: SearchServiceClient) { - client.close(); -} -function doStuffWithServingConfigServiceClient(client: ServingConfigServiceClient) { - client.close(); -} -function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const catalogServiceClient = new CatalogServiceClient(); - doStuffWithCatalogServiceClient(catalogServiceClient); - // check that the client instance can be created - const completionServiceClient = new CompletionServiceClient(); - doStuffWithCompletionServiceClient(completionServiceClient); - // check that the client instance can be created - const controlServiceClient = new ControlServiceClient(); - doStuffWithControlServiceClient(controlServiceClient); - // check that the client instance can be created - const predictionServiceClient = new PredictionServiceClient(); - doStuffWithPredictionServiceClient(predictionServiceClient); - // check that the client instance can be created - const productServiceClient = new ProductServiceClient(); - doStuffWithProductServiceClient(productServiceClient); - // check that the client instance can be created - const searchServiceClient = new SearchServiceClient(); - doStuffWithSearchServiceClient(searchServiceClient); - // check that the client instance can be created - const servingConfigServiceClient = new ServingConfigServiceClient(); - doStuffWithServingConfigServiceClient(servingConfigServiceClient); - // check that the client instance can be created - const userEventServiceClient = new UserEventServiceClient(); - doStuffWithUserEventServiceClient(userEventServiceClient); -} - -main(); diff --git a/owl-bot-staging/v2beta/system-test/install.ts b/owl-bot-staging/v2beta/system-test/install.ts deleted file mode 100644 index 8ec45222..00000000 --- a/owl-bot-staging/v2beta/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/v2beta/test/gapic_catalog_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts deleted file mode 100644 index c264bc2d..00000000 --- a/owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts +++ /dev/null @@ -1,1790 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as catalogserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.CatalogServiceClient', () => { - it('has servicePath', () => { - const servicePath = catalogserviceModule.v2beta.CatalogServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = catalogserviceModule.v2beta.CatalogServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = catalogserviceModule.v2beta.CatalogServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - await client.initialize(); - assert(client.catalogServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.catalogServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('updateCatalog', () => { - it('invokes updateCatalog without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); - const [response] = await client.updateCatalog(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCatalog( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICatalog|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCatalog with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCatalog(request), expectedError); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCatalog(request), expectedError); - }); - }); - - describe('setDefaultBranch', () => { - it('invokes setDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.setDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setDefaultBranch( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setDefaultBranch(request), expectedError); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setDefaultBranch(request), expectedError); - }); - }); - - describe('getDefaultBranch', () => { - it('invokes getDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.getDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDefaultBranch( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDefaultBranch(request), expectedError); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDefaultBranch(request), expectedError); - }); - }); - - describe('getCompletionConfig', () => { - it('invokes getCompletionConfig without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCompletionConfig without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); - client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getCompletionConfig with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCompletionConfig(request), expectedError); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCompletionConfig with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getCompletionConfig(request), expectedError); - }); - }); - - describe('updateCompletionConfig', () => { - it('invokes updateCompletionConfig without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCompletionConfig without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); - client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCompletionConfig with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCompletionConfig with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - }); - }); - - describe('getAttributesConfig', () => { - it('invokes getAttributesConfig without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAttributesConfig without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getAttributesConfig with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttributesConfig(request), expectedError); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAttributesConfig with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAttributesConfig(request), expectedError); - }); - }); - - describe('updateAttributesConfig', () => { - it('invokes updateAttributesConfig without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAttributesConfig without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateAttributesConfig with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAttributesConfig with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - }); - }); - - describe('addCatalogAttribute', () => { - it('invokes addCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.addCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - }); - }); - - describe('removeCatalogAttribute', () => { - it('invokes removeCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.removeCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - }); - }); - - describe('replaceCatalogAttribute', () => { - it('invokes replaceCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.replaceCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes replaceCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.replaceCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes replaceCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes replaceCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - }); - }); - - describe('listCatalogs', () => { - it('invokes listCatalogs without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); - const [response] = await client.listCatalogs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogs without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCatalogs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICatalog[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listCatalogs with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCatalogs(request), expectedError); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogsStream without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - ]; - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listCatalogsStream with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - ]; - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; - const iterable = client.listCatalogsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCatalogsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts deleted file mode 100644 index 26af45db..00000000 --- a/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts +++ /dev/null @@ -1,703 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as completionserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2beta.CompletionServiceClient', () => { - it('has servicePath', () => { - const servicePath = completionserviceModule.v2beta.CompletionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = completionserviceModule.v2beta.CompletionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = completionserviceModule.v2beta.CompletionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - await client.initialize(); - assert(client.completionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.completionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery without error using callback', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes completeQuery with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery with closed client', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.completeQuery(request), expectedError); - }); - }); - - describe('importCompletionData', () => { - it('invokes importCompletionData without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); - const [operation] = await client.importCompletionData(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData without error using callback', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importCompletionData( - request, - (err?: Error|null, - result?: LROperation|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.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importCompletionData with call error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importCompletionData(request), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData with LRO error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importCompletionData(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportCompletionDataProgress without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportCompletionDataProgress with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts deleted file mode 100644 index 4ba4bd3c..00000000 --- a/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts +++ /dev/null @@ -1,1108 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as controlserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.ControlServiceClient', () => { - it('has servicePath', () => { - const servicePath = controlserviceModule.v2beta.ControlServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = controlserviceModule.v2beta.ControlServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = controlserviceModule.v2beta.ControlServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new controlserviceModule.v2beta.ControlServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.controlServiceStub, undefined); - await client.initialize(); - assert(client.controlServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.controlServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.controlServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createControl', () => { - it('invokes createControl without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); - const [response] = await client.createControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createControl without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createControl with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createControl(request), expectedError); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createControl with closed client', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createControl(request), expectedError); - }); - }); - - describe('deleteControl', () => { - it('invokes deleteControl without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); - const [response] = await client.deleteControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteControl without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteControl( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteControl with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteControl(request), expectedError); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteControl with closed client', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteControl(request), expectedError); - }); - }); - - describe('updateControl', () => { - it('invokes updateControl without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); - const [response] = await client.updateControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateControl without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateControl with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateControl(request), expectedError); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateControl with closed client', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateControl(request), expectedError); - }); - }); - - describe('getControl', () => { - it('invokes getControl without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); - const [response] = await client.getControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getControl without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getControl with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getControl(request), expectedError); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getControl with closed client', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getControl(request), expectedError); - }); - }); - - describe('listControls', () => { - it('invokes listControls without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); - const [response] = await client.listControls(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listControls without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listControls( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listControls with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listControls(request), expectedError); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listControlsStream without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - ]; - client.descriptors.page.listControls.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listControlsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Control) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listControls, request)); - assert.strictEqual( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listControlsStream with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listControls.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listControlsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Control) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listControls, request)); - assert.strictEqual( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listControls without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - ]; - client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.IControl[] = []; - const iterable = client.listControlsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listControls with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listControlsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2beta.IControl[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts deleted file mode 100644 index ca636e40..00000000 --- a/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as predictionserviceModule from '../src'; - -import {protobuf} 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('v2beta.PredictionServiceClient', () => { - it('has servicePath', () => { - const servicePath = predictionserviceModule.v2beta.PredictionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = predictionserviceModule.v2beta.PredictionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = predictionserviceModule.v2beta.PredictionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - await client.initialize(); - assert(client.predictionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.predictionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('predict', () => { - it('invokes predict without error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCall(expectedResponse); - const [response] = await client.predict(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict without error using callback', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.predict( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IPredictResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes predict with error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.predict(request), expectedError); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict with closed client', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); - request.placement = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.predict(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts deleted file mode 100644 index b483f593..00000000 --- a/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts +++ /dev/null @@ -1,2046 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as productserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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('v2beta.ProductServiceClient', () => { - it('has servicePath', () => { - const servicePath = productserviceModule.v2beta.ProductServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productserviceModule.v2beta.ProductServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productserviceModule.v2beta.ProductServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productserviceModule.v2beta.ProductServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - await client.initialize(); - assert(client.productServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('importProducts', () => { - it('invokes importProducts without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProducts( - request, - (err?: Error|null, - result?: LROperation|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.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProducts with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProducts(request), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductsProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductsProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInventory', () => { - it('invokes setInventory without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInventory(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInventory( - request, - (err?: Error|null, - result?: LROperation|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.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setInventory with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInventory(request), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInventory(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkSetInventoryProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInventoryProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInventoryProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addFulfillmentPlaces', () => { - it('invokes addFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeFulfillmentPlaces', () => { - it('invokes removeFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addLocalInventories', () => { - it('invokes addLocalInventories without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.addLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addLocalInventories with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addLocalInventories(request), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeLocalInventories', () => { - it('invokes removeLocalInventories without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeLocalInventories with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeLocalInventories(request), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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.retail.v2beta.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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.retail.v2beta.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts deleted file mode 100644 index f654dd43..00000000 --- a/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts +++ /dev/null @@ -1,770 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as searchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.SearchServiceClient', () => { - it('has servicePath', () => { - const servicePath = searchserviceModule.v2beta.SearchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = searchserviceModule.v2beta.SearchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = searchserviceModule.v2beta.SearchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new searchserviceModule.v2beta.SearchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - await client.initialize(); - assert(client.searchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.searchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('search', () => { - it('invokes search without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCall(expectedResponse); - const [response] = await client.search(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes search without error using callback', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.search( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes search with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchStream without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes searchStream with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedError = new Error('expected'); - client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = []; - const iterable = client.searchAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts deleted file mode 100644 index f7adf822..00000000 --- a/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts +++ /dev/null @@ -1,1302 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as servingconfigserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.ServingConfigServiceClient', () => { - it('has servicePath', () => { - const servicePath = servingconfigserviceModule.v2beta.ServingConfigServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = servingconfigserviceModule.v2beta.ServingConfigServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = servingconfigserviceModule.v2beta.ServingConfigServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servingConfigServiceStub, undefined); - await client.initialize(); - assert(client.servingConfigServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.servingConfigServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servingConfigServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createServingConfig', () => { - it('invokes createServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.createServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createServingConfig(request), expectedError); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createServingConfig(request), expectedError); - }); - }); - - describe('deleteServingConfig', () => { - it('invokes deleteServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.deleteServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServingConfig( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteServingConfig(request), expectedError); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteServingConfig(request), expectedError); - }); - }); - - describe('updateServingConfig', () => { - it('invokes updateServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateServingConfig(request), expectedError); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateServingConfig(request), expectedError); - }); - }); - - describe('getServingConfig', () => { - it('invokes getServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServingConfig(request), expectedError); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getServingConfig(request), expectedError); - }); - }); - - describe('addControl', () => { - it('invokes addControl without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); - const [response] = await client.addControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addControl with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addControl(request), expectedError); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addControl with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); - request.servingConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addControl(request), expectedError); - }); - }); - - describe('removeControl', () => { - it('invokes removeControl without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); - const [response] = await client.removeControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeControl with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeControl(request), expectedError); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeControl with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); - request.servingConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeControl(request), expectedError); - }); - }); - - describe('listServingConfigs', () => { - it('invokes listServingConfigs without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listServingConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServingConfigs without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServingConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServingConfigs(request), expectedError); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServingConfigsStream without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - ]; - client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServingConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.ServingConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listServingConfigsStream with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServingConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.ServingConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServingConfigs without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - ]; - client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = []; - const iterable = client.listServingConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServingConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts deleted file mode 100644 index dd385461..00000000 --- a/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts +++ /dev/null @@ -1,1088 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as usereventserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2beta.UserEventServiceClient', () => { - it('has servicePath', () => { - const servicePath = usereventserviceModule.v2beta.UserEventServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = usereventserviceModule.v2beta.UserEventServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = usereventserviceModule.v2beta.UserEventServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - await client.initialize(); - assert(client.userEventServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.userEventServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('writeUserEvent', () => { - it('invokes writeUserEvent without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.writeUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.writeUserEvent( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IUserEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes writeUserEvent with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.writeUserEvent(request), expectedError); - }); - }); - - describe('collectUserEvent', () => { - it('invokes collectUserEvent without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.collectUserEvent( - request, - (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes collectUserEvent with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.collectUserEvent(request), expectedError); - }); - }); - - describe('purgeUserEvents', () => { - it('invokes purgeUserEvents without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeUserEvents with call error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeUserEvents(request), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importUserEvents', () => { - it('invokes importUserEvents without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.importUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importUserEvents with call error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rejoinUserEvents', () => { - it('invokes rejoinUserEvents without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejoinUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejoinUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes rejoinUserEvents with call error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejoinUserEvents(request), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejoinUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRejoinUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRejoinUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/tsconfig.json b/owl-bot-staging/v2beta/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v2beta/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/v2beta/webpack.config.js b/owl-bot-staging/v2beta/webpack.config.js deleted file mode 100644 index f2c58f25..00000000 --- a/owl-bot-staging/v2beta/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: 'CatalogService', - filename: './catalog-service.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/protos/google/cloud/retail/v2alpha/catalog.proto b/protos/google/cloud/retail/v2alpha/catalog.proto index 8dcb23f6..9b3d8cb0 100644 --- a/protos/google/cloud/retail/v2alpha/catalog.proto +++ b/protos/google/cloud/retail/v2alpha/catalog.proto @@ -204,7 +204,7 @@ message AttributesConfig { }; // Required. Immutable. The fully qualified resource name of the attribute - // config. Format: "projects/*/locations/*/catalogs/*/attributesConfig" + // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.field_behavior) = IMMUTABLE @@ -237,7 +237,7 @@ message CompletionConfig { }; // Required. Immutable. Fully qualified name - // projects/*/locations/*/catalogs/*/completionConfig + // `projects/*/locations/*/catalogs/*/completionConfig` string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.field_behavior) = IMMUTABLE diff --git a/protos/google/cloud/retail/v2beta/catalog.proto b/protos/google/cloud/retail/v2beta/catalog.proto index e6d768f5..e0b844ef 100644 --- a/protos/google/cloud/retail/v2beta/catalog.proto +++ b/protos/google/cloud/retail/v2beta/catalog.proto @@ -204,7 +204,7 @@ message AttributesConfig { }; // Required. Immutable. The fully qualified resource name of the attribute - // config. Format: "projects/*/locations/*/catalogs/*/attributesConfig" + // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.field_behavior) = IMMUTABLE @@ -237,7 +237,7 @@ message CompletionConfig { }; // Required. Immutable. Fully qualified name - // projects/*/locations/*/catalogs/*/completionConfig + // `projects/*/locations/*/catalogs/*/completionConfig` string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.field_behavior) = IMMUTABLE From b7e0fe9b6491e8ccc38c3d63663040c69cc1bbd9 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 1 Jun 2022 03:49:06 +0000 Subject: [PATCH 3/4] feat: allow users to disable spell check in search requests feat: allow users to add labels in search requests docs: deprecate indexable/searchable on the product level custom attributes docs: keep the API doc up-to-date with recent changes PiperOrigin-RevId: 452193046 Source-Link: https://github.com/googleapis/googleapis/commit/4e0282f92e4e581b79062063488bf62fa837a905 Source-Link: https://github.com/googleapis/googleapis-gen/commit/3fa3c84e3da8c8e604e129c141367dd0926878f3 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiM2ZhM2M4NGUzZGE4YzhlNjA0ZTEyOWMxNDEzNjdkZDA5MjY4NzhmMyJ9 --- owl-bot-staging/v2/.eslintignore | 7 + owl-bot-staging/v2/.eslintrc.json | 3 + owl-bot-staging/v2/.gitignore | 14 + owl-bot-staging/v2/.jsdoc.js | 55 + owl-bot-staging/v2/.mocharc.js | 33 + owl-bot-staging/v2/.prettierrc.js | 22 + owl-bot-staging/v2/README.md | 1 + owl-bot-staging/v2/linkinator.config.json | 16 + owl-bot-staging/v2/package.json | 69 + .../google/cloud/retail/v2/catalog.proto | 110 + .../cloud/retail/v2/catalog_service.proto | 246 ++ .../google/cloud/retail/v2/common.proto | 491 +++ .../cloud/retail/v2/completion_service.proto | 205 ++ .../cloud/retail/v2/import_config.proto | 401 +++ .../cloud/retail/v2/prediction_service.proto | 204 ++ .../google/cloud/retail/v2/product.proto | 558 ++++ .../cloud/retail/v2/product_service.proto | 838 ++++++ .../google/cloud/retail/v2/promotion.proto | 40 + .../google/cloud/retail/v2/purge_config.proto | 82 + .../cloud/retail/v2/search_service.proto | 854 ++++++ .../google/cloud/retail/v2/user_event.proto | 343 +++ .../cloud/retail/v2/user_event_service.proto | 190 ++ .../v2/catalog_service.get_default_branch.js | 58 + .../v2/catalog_service.list_catalogs.js | 83 + .../v2/catalog_service.set_default_branch.js | 81 + .../v2/catalog_service.update_catalog.js | 70 + .../v2/completion_service.complete_query.js | 116 + ...mpletion_service.import_completion_data.js | 73 + .../v2/prediction_service.predict.js | 170 ++ .../product_service.add_fulfillment_places.js | 115 + .../product_service.add_local_inventories.js | 99 + .../v2/product_service.create_product.js | 80 + .../v2/product_service.delete_product.js | 74 + .../v2/product_service.get_product.js | 65 + .../v2/product_service.import_products.js | 99 + .../v2/product_service.list_products.js | 130 + ...oduct_service.remove_fulfillment_places.js | 112 + ...roduct_service.remove_local_inventories.js | 85 + .../v2/product_service.set_inventory.js | 124 + .../v2/product_service.update_product.js | 84 + .../generated/v2/search_service.search.js | 288 ++ ...ippet_metadata.google.cloud.retail.v2.json | 1303 ++++++++ .../user_event_service.collect_user_event.js | 78 + .../user_event_service.import_user_events.js | 69 + .../user_event_service.purge_user_events.js | 90 + .../user_event_service.rejoin_user_events.js | 67 + .../v2/user_event_service.write_user_event.js | 64 + owl-bot-staging/v2/src/index.ts | 35 + .../v2/src/v2/catalog_service_client.ts | 1058 +++++++ .../src/v2/catalog_service_client_config.json | 55 + .../v2/src/v2/catalog_service_proto_list.json | 15 + .../v2/src/v2/completion_service_client.ts | 701 +++++ .../v2/completion_service_client_config.json | 45 + .../src/v2/completion_service_proto_list.json | 15 + owl-bot-staging/v2/src/v2/gapic_metadata.json | 345 +++ owl-bot-staging/v2/src/v2/index.ts | 24 + .../v2/src/v2/prediction_service_client.ts | 613 ++++ .../v2/prediction_service_client_config.json | 40 + .../src/v2/prediction_service_proto_list.json | 15 + .../v2/src/v2/product_service_client.ts | 2223 ++++++++++++++ .../src/v2/product_service_client_config.json | 99 + .../v2/src/v2/product_service_proto_list.json | 15 + .../v2/src/v2/search_service_client.ts | 1324 +++++++++ .../src/v2/search_service_client_config.json | 40 + .../v2/src/v2/search_service_proto_list.json | 15 + .../v2/src/v2/user_event_service_client.ts | 966 ++++++ .../v2/user_event_service_client_config.json | 78 + .../src/v2/user_event_service_proto_list.json | 15 + .../system-test/fixtures/sample/src/index.js | 32 + .../system-test/fixtures/sample/src/index.ts | 62 + owl-bot-staging/v2/system-test/install.ts | 49 + .../v2/test/gapic_catalog_service_v2.ts | 903 ++++++ .../v2/test/gapic_completion_service_v2.ts | 503 ++++ .../v2/test/gapic_prediction_service_v2.ts | 343 +++ .../v2/test/gapic_product_service_v2.ts | 1846 ++++++++++++ .../v2/test/gapic_search_service_v2.ts | 570 ++++ .../v2/test/gapic_user_event_service_v2.ts | 888 ++++++ owl-bot-staging/v2/tsconfig.json | 19 + owl-bot-staging/v2/webpack.config.js | 64 + owl-bot-staging/v2alpha/.eslintignore | 7 + owl-bot-staging/v2alpha/.eslintrc.json | 3 + owl-bot-staging/v2alpha/.gitignore | 14 + owl-bot-staging/v2alpha/.jsdoc.js | 55 + owl-bot-staging/v2alpha/.mocharc.js | 33 + owl-bot-staging/v2alpha/.prettierrc.js | 22 + owl-bot-staging/v2alpha/README.md | 1 + .../v2alpha/linkinator.config.json | 16 + owl-bot-staging/v2alpha/package.json | 71 + .../google/cloud/retail/v2alpha/catalog.proto | 397 +++ .../retail/v2alpha/catalog_service.proto | 478 +++ .../google/cloud/retail/v2alpha/common.proto | 761 +++++ .../retail/v2alpha/completion_service.proto | 199 ++ .../google/cloud/retail/v2alpha/control.proto | 92 + .../retail/v2alpha/control_service.proto | 184 ++ .../cloud/retail/v2alpha/export_config.proto | 77 + .../cloud/retail/v2alpha/import_config.proto | 397 +++ .../retail/v2alpha/prediction_service.proto | 194 ++ .../google/cloud/retail/v2alpha/product.proto | 567 ++++ .../retail/v2alpha/product_service.proto | 882 ++++++ .../cloud/retail/v2alpha/promotion.proto | 40 + .../cloud/retail/v2alpha/purge_config.proto | 171 ++ .../cloud/retail/v2alpha/search_service.proto | 832 ++++++ .../cloud/retail/v2alpha/serving_config.proto | 247 ++ .../v2alpha/serving_config_service.proto | 241 ++ .../cloud/retail/v2alpha/user_event.proto | 344 +++ .../retail/v2alpha/user_event_service.proto | 190 ++ .../catalog_service.add_catalog_attribute.js | 65 + .../catalog_service.get_attributes_config.js | 59 + .../catalog_service.get_completion_config.js | 59 + .../catalog_service.get_default_branch.js | 58 + .../v2alpha/catalog_service.list_catalogs.js | 83 + ...atalog_service.remove_catalog_attribute.js | 65 + ...talog_service.replace_catalog_attribute.js | 73 + .../catalog_service.set_default_branch.js | 81 + ...atalog_service.update_attributes_config.js | 67 + .../v2alpha/catalog_service.update_catalog.js | 70 + ...atalog_service.update_completion_config.js | 75 + .../completion_service.complete_query.js | 117 + ...mpletion_service.import_completion_data.js | 73 + .../v2alpha/control_service.create_control.js | 72 + .../v2alpha/control_service.delete_control.js | 59 + .../v2alpha/control_service.get_control.js | 59 + .../v2alpha/control_service.list_controls.js | 79 + .../v2alpha/control_service.update_control.js | 66 + .../v2alpha/prediction_service.predict.js | 161 + .../product_service.add_fulfillment_places.js | 115 + .../product_service.add_local_inventories.js | 100 + .../v2alpha/product_service.create_product.js | 80 + .../v2alpha/product_service.delete_product.js | 75 + .../v2alpha/product_service.get_product.js | 65 + .../product_service.import_products.js | 93 + .../v2alpha/product_service.list_products.js | 141 + .../v2alpha/product_service.purge_products.js | 101 + ...oduct_service.remove_fulfillment_places.js | 111 + ...roduct_service.remove_local_inventories.js | 85 + .../v2alpha/product_service.set_inventory.js | 124 + .../v2alpha/product_service.update_product.js | 80 + .../v2alpha/search_service.search.js | 281 ++ .../serving_config_service.add_control.js | 65 + ...ng_config_service.create_serving_config.js | 72 + ...ng_config_service.delete_serving_config.js | 59 + ...rving_config_service.get_serving_config.js | 59 + ...ing_config_service.list_serving_configs.js | 72 + .../serving_config_service.remove_control.js | 65 + ...ng_config_service.update_serving_config.js | 66 + ..._metadata.google.cloud.retail.v2alpha.json | 2187 ++++++++++++++ .../user_event_service.collect_user_event.js | 78 + .../user_event_service.import_user_events.js | 69 + .../user_event_service.purge_user_events.js | 91 + .../user_event_service.rejoin_user_events.js | 67 + .../user_event_service.write_user_event.js | 64 + owl-bot-staging/v2alpha/src/index.ts | 39 + .../src/v2alpha/catalog_service_client.ts | 1865 ++++++++++++ .../catalog_service_client_config.json | 90 + .../v2alpha/catalog_service_proto_list.json | 20 + .../src/v2alpha/completion_service_client.ts | 936 ++++++ .../completion_service_client_config.json | 45 + .../completion_service_proto_list.json | 20 + .../src/v2alpha/control_service_client.ts | 1195 ++++++++ .../control_service_client_config.json | 46 + .../v2alpha/control_service_proto_list.json | 20 + .../v2alpha/src/v2alpha/gapic_metadata.json | 581 ++++ owl-bot-staging/v2alpha/src/v2alpha/index.ts | 26 + .../src/v2alpha/prediction_service_client.ts | 837 ++++++ .../prediction_service_client_config.json | 40 + .../prediction_service_proto_list.json | 20 + .../src/v2alpha/product_service_client.ts | 2641 +++++++++++++++++ .../product_service_client_config.json | 104 + .../v2alpha/product_service_proto_list.json | 20 + .../src/v2alpha/search_service_client.ts | 1537 ++++++++++ .../v2alpha/search_service_client_config.json | 40 + .../v2alpha/search_service_proto_list.json | 20 + .../v2alpha/serving_config_service_client.ts | 1334 +++++++++ .../serving_config_service_client_config.json | 54 + .../serving_config_service_proto_list.json | 20 + .../src/v2alpha/user_event_service_client.ts | 1201 ++++++++ .../user_event_service_client_config.json | 78 + .../user_event_service_proto_list.json | 20 + .../system-test/fixtures/sample/src/index.js | 34 + .../system-test/fixtures/sample/src/index.ts | 74 + .../v2alpha/system-test/install.ts | 49 + .../test/gapic_catalog_service_v2alpha.ts | 1790 +++++++++++ .../test/gapic_completion_service_v2alpha.ts | 703 +++++ .../test/gapic_control_service_v2alpha.ts | 1108 +++++++ .../test/gapic_prediction_service_v2alpha.ts | 543 ++++ .../test/gapic_product_service_v2alpha.ts | 2190 ++++++++++++++ .../test/gapic_search_service_v2alpha.ts | 770 +++++ .../gapic_serving_config_service_v2alpha.ts | 1302 ++++++++ .../test/gapic_user_event_service_v2alpha.ts | 1088 +++++++ owl-bot-staging/v2alpha/tsconfig.json | 19 + owl-bot-staging/v2alpha/webpack.config.js | 64 + owl-bot-staging/v2beta/.eslintignore | 7 + owl-bot-staging/v2beta/.eslintrc.json | 3 + owl-bot-staging/v2beta/.gitignore | 14 + owl-bot-staging/v2beta/.jsdoc.js | 55 + owl-bot-staging/v2beta/.mocharc.js | 33 + owl-bot-staging/v2beta/.prettierrc.js | 22 + owl-bot-staging/v2beta/README.md | 1 + owl-bot-staging/v2beta/linkinator.config.json | 16 + owl-bot-staging/v2beta/package.json | 71 + .../google/cloud/retail/v2beta/catalog.proto | 397 +++ .../cloud/retail/v2beta/catalog_service.proto | 478 +++ .../google/cloud/retail/v2beta/common.proto | 760 +++++ .../retail/v2beta/completion_service.proto | 199 ++ .../google/cloud/retail/v2beta/control.proto | 84 + .../cloud/retail/v2beta/control_service.proto | 184 ++ .../cloud/retail/v2beta/export_config.proto | 77 + .../cloud/retail/v2beta/import_config.proto | 397 +++ .../retail/v2beta/prediction_service.proto | 194 ++ .../google/cloud/retail/v2beta/product.proto | 566 ++++ .../cloud/retail/v2beta/product_service.proto | 829 ++++++ .../cloud/retail/v2beta/promotion.proto | 40 + .../cloud/retail/v2beta/purge_config.proto | 80 + .../cloud/retail/v2beta/search_service.proto | 791 +++++ .../cloud/retail/v2beta/serving_config.proto | 247 ++ .../v2beta/serving_config_service.proto | 240 ++ .../cloud/retail/v2beta/user_event.proto | 342 +++ .../retail/v2beta/user_event_service.proto | 190 ++ .../catalog_service.add_catalog_attribute.js | 65 + .../catalog_service.get_attributes_config.js | 59 + .../catalog_service.get_completion_config.js | 59 + .../catalog_service.get_default_branch.js | 58 + .../v2beta/catalog_service.list_catalogs.js | 83 + ...atalog_service.remove_catalog_attribute.js | 65 + ...talog_service.replace_catalog_attribute.js | 73 + .../catalog_service.set_default_branch.js | 81 + ...atalog_service.update_attributes_config.js | 67 + .../v2beta/catalog_service.update_catalog.js | 70 + ...atalog_service.update_completion_config.js | 75 + .../completion_service.complete_query.js | 117 + ...mpletion_service.import_completion_data.js | 73 + .../v2beta/control_service.create_control.js | 72 + .../v2beta/control_service.delete_control.js | 59 + .../v2beta/control_service.get_control.js | 59 + .../v2beta/control_service.list_controls.js | 79 + .../v2beta/control_service.update_control.js | 66 + .../v2beta/prediction_service.predict.js | 161 + .../product_service.add_fulfillment_places.js | 115 + .../product_service.add_local_inventories.js | 100 + .../v2beta/product_service.create_product.js | 80 + .../v2beta/product_service.delete_product.js | 75 + .../v2beta/product_service.get_product.js | 65 + .../v2beta/product_service.import_products.js | 93 + .../v2beta/product_service.list_products.js | 132 + ...oduct_service.remove_fulfillment_places.js | 111 + ...roduct_service.remove_local_inventories.js | 85 + .../v2beta/product_service.set_inventory.js | 124 + .../v2beta/product_service.update_product.js | 80 + .../generated/v2beta/search_service.search.js | 261 ++ .../serving_config_service.add_control.js | 65 + ...ng_config_service.create_serving_config.js | 72 + ...ng_config_service.delete_serving_config.js | 59 + ...rving_config_service.get_serving_config.js | 59 + ...ing_config_service.list_serving_configs.js | 72 + .../serving_config_service.remove_control.js | 65 + ...ng_config_service.update_serving_config.js | 66 + ...t_metadata.google.cloud.retail.v2beta.json | 2131 +++++++++++++ .../user_event_service.collect_user_event.js | 78 + .../user_event_service.import_user_events.js | 69 + .../user_event_service.purge_user_events.js | 91 + .../user_event_service.rejoin_user_events.js | 67 + .../user_event_service.write_user_event.js | 64 + owl-bot-staging/v2beta/src/index.ts | 39 + .../src/v2beta/catalog_service_client.ts | 1865 ++++++++++++ .../v2beta/catalog_service_client_config.json | 90 + .../v2beta/catalog_service_proto_list.json | 20 + .../src/v2beta/completion_service_client.ts | 936 ++++++ .../completion_service_client_config.json | 45 + .../v2beta/completion_service_proto_list.json | 20 + .../src/v2beta/control_service_client.ts | 1195 ++++++++ .../v2beta/control_service_client_config.json | 46 + .../v2beta/control_service_proto_list.json | 20 + .../v2beta/src/v2beta/gapic_metadata.json | 571 ++++ owl-bot-staging/v2beta/src/v2beta/index.ts | 26 + .../src/v2beta/prediction_service_client.ts | 837 ++++++ .../prediction_service_client_config.json | 40 + .../v2beta/prediction_service_proto_list.json | 20 + .../src/v2beta/product_service_client.ts | 2455 +++++++++++++++ .../v2beta/product_service_client_config.json | 99 + .../v2beta/product_service_proto_list.json | 20 + .../src/v2beta/search_service_client.ts | 1480 +++++++++ .../v2beta/search_service_client_config.json | 40 + .../src/v2beta/search_service_proto_list.json | 20 + .../v2beta/serving_config_service_client.ts | 1333 +++++++++ .../serving_config_service_client_config.json | 54 + .../serving_config_service_proto_list.json | 20 + .../src/v2beta/user_event_service_client.ts | 1201 ++++++++ .../user_event_service_client_config.json | 78 + .../v2beta/user_event_service_proto_list.json | 20 + .../system-test/fixtures/sample/src/index.js | 34 + .../system-test/fixtures/sample/src/index.ts | 74 + owl-bot-staging/v2beta/system-test/install.ts | 49 + .../test/gapic_catalog_service_v2beta.ts | 1790 +++++++++++ .../test/gapic_completion_service_v2beta.ts | 703 +++++ .../test/gapic_control_service_v2beta.ts | 1108 +++++++ .../test/gapic_prediction_service_v2beta.ts | 543 ++++ .../test/gapic_product_service_v2beta.ts | 2046 +++++++++++++ .../test/gapic_search_service_v2beta.ts | 770 +++++ .../gapic_serving_config_service_v2beta.ts | 1302 ++++++++ .../test/gapic_user_event_service_v2beta.ts | 1088 +++++++ owl-bot-staging/v2beta/tsconfig.json | 19 + owl-bot-staging/v2beta/webpack.config.js | 64 + 302 files changed, 90695 insertions(+) create mode 100644 owl-bot-staging/v2/.eslintignore create mode 100644 owl-bot-staging/v2/.eslintrc.json create mode 100644 owl-bot-staging/v2/.gitignore create mode 100644 owl-bot-staging/v2/.jsdoc.js create mode 100644 owl-bot-staging/v2/.mocharc.js create mode 100644 owl-bot-staging/v2/.prettierrc.js create mode 100644 owl-bot-staging/v2/README.md create mode 100644 owl-bot-staging/v2/linkinator.config.json create mode 100644 owl-bot-staging/v2/package.json create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto create mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/search_service.search.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/v2/src/index.ts create mode 100644 owl-bot-staging/v2/src/v2/catalog_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/catalog_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/catalog_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/completion_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/completion_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/completion_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/gapic_metadata.json create mode 100644 owl-bot-staging/v2/src/v2/index.ts create mode 100644 owl-bot-staging/v2/src/v2/prediction_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/prediction_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/prediction_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/product_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/product_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/product_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/search_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/search_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/search_service_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/user_event_service_client.ts create mode 100644 owl-bot-staging/v2/src/v2/user_event_service_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/user_event_service_proto_list.json create mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v2/system-test/install.ts create mode 100644 owl-bot-staging/v2/test/gapic_catalog_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_completion_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_prediction_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_product_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_search_service_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_user_event_service_v2.ts create mode 100644 owl-bot-staging/v2/tsconfig.json create mode 100644 owl-bot-staging/v2/webpack.config.js create mode 100644 owl-bot-staging/v2alpha/.eslintignore create mode 100644 owl-bot-staging/v2alpha/.eslintrc.json create mode 100644 owl-bot-staging/v2alpha/.gitignore create mode 100644 owl-bot-staging/v2alpha/.jsdoc.js create mode 100644 owl-bot-staging/v2alpha/.mocharc.js create mode 100644 owl-bot-staging/v2alpha/.prettierrc.js create mode 100644 owl-bot-staging/v2alpha/README.md create mode 100644 owl-bot-staging/v2alpha/linkinator.config.json create mode 100644 owl-bot-staging/v2alpha/package.json create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto create mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js create mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/v2alpha/src/index.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/index.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json create mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json create mode 100644 owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v2alpha/system-test/install.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts create mode 100644 owl-bot-staging/v2alpha/tsconfig.json create mode 100644 owl-bot-staging/v2alpha/webpack.config.js create mode 100644 owl-bot-staging/v2beta/.eslintignore create mode 100644 owl-bot-staging/v2beta/.eslintrc.json create mode 100644 owl-bot-staging/v2beta/.gitignore create mode 100644 owl-bot-staging/v2beta/.jsdoc.js create mode 100644 owl-bot-staging/v2beta/.mocharc.js create mode 100644 owl-bot-staging/v2beta/.prettierrc.js create mode 100644 owl-bot-staging/v2beta/README.md create mode 100644 owl-bot-staging/v2beta/linkinator.config.json create mode 100644 owl-bot-staging/v2beta/package.json create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto create mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js create mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/v2beta/src/index.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/index.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts create mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json create mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json create mode 100644 owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v2beta/system-test/install.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts create mode 100644 owl-bot-staging/v2beta/tsconfig.json create mode 100644 owl-bot-staging/v2beta/webpack.config.js diff --git a/owl-bot-staging/v2/.eslintignore b/owl-bot-staging/v2/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v2/.eslintrc.json b/owl-bot-staging/v2/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v2/.gitignore b/owl-bot-staging/v2/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v2/.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/v2/.jsdoc.js b/owl-bot-staging/v2/.jsdoc.js new file mode 100644 index 00000000..19729810 --- /dev/null +++ b/owl-bot-staging/v2/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v2/.mocharc.js b/owl-bot-staging/v2/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v2/.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/v2/.prettierrc.js b/owl-bot-staging/v2/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v2/.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/v2/README.md b/owl-bot-staging/v2/README.md new file mode 100644 index 00000000..822c4573 --- /dev/null +++ b/owl-bot-staging/v2/README.md @@ -0,0 +1 @@ +Retail: Nodejs Client diff --git a/owl-bot-staging/v2/linkinator.config.json b/owl-bot-staging/v2/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v2/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/v2/package.json b/owl-bot-staging/v2/package.json new file mode 100644 index 00000000..09d9ddf3 --- /dev/null +++ b/owl-bot-staging/v2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@google-cloud/retail", + "version": "0.1.0", + "description": "Retail client for Node.js", + "repository": "googleapis/nodejs-retail", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google retail", + "retail", + "catalog service", + "completion service", + "prediction service", + "product service", + "search service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto new file mode 100644 index 00000000..119afaf3 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto @@ -0,0 +1,110 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Configures what level the product should be uploaded with regards to +// how users will be send events and how predictions will be made. +message ProductLevelConfig { + // The type of [Product][google.cloud.retail.v2.Product]s allowed to be + // ingested into the catalog. Acceptable values are: + // + // * `primary` (default): You can ingest + // [Product][google.cloud.retail.v2.Product]s of all types. When + // ingesting a [Product][google.cloud.retail.v2.Product], its type will + // default to + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] if + // unset. + // * `variant` (incompatible with Retail Search): You can only + // ingest + // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. This means + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] + // cannot be empty. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `variant` and + // [merchant_center_product_id_field][google.cloud.retail.v2.ProductLevelConfig.merchant_center_product_id_field] + // is `itemGroupId`, an INVALID_ARGUMENT error is returned. + // + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) + // for more details. + string ingestion_product_type = 1; + + // Which field of [Merchant Center + // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be + // imported as [Product.id][google.cloud.retail.v2.Product.id]. Acceptable + // values are: + // + // * `offerId` (default): Import `offerId` as the product ID. + // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail + // API will choose one item from the ones with the same `itemGroupId`, and + // use it to represent the item group. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `itemGroupId` and + // [ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] + // is `variant`, an INVALID_ARGUMENT error is returned. + // + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) + // for more details. + string merchant_center_product_id_field = 2; +} + +// The catalog configuration. +message Catalog { + option (google.api.resource) = { + type: "retail.googleapis.com/Catalog" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" + }; + + // Required. Immutable. The fully qualified resource name of the catalog. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The catalog display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. The product level configuration. + ProductLevelConfig product_level_config = 4 + [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto new file mode 100644 index 00000000..ec7a23a8 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto @@ -0,0 +1,246 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/catalog.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for managing catalog configuration. +service CatalogService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with + // the project. + rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/catalogs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates the [Catalog][google.cloud.retail.v2.Catalog]s. + rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { + option (google.api.http) = { + patch: "/v2/{catalog.name=projects/*/locations/*/catalogs/*}" + body: "catalog" + }; + option (google.api.method_signature) = "catalog,update_mask"; + } + + // Set a specified branch id as default branch. API methods such as + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search], + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + // will treat requests using "default_branch" to the actual branch id set as + // default. + // + // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + // default, setting + // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + // to setting + // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/1`. + // + // Using multiple branches can be useful when developers would like + // to have a staging branch to test and verify for future usage. When it + // becomes ready, developers switch on the staging branch using this API while + // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + // as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + // route the traffic to this staging branch. + // + // CAUTION: If you have live predict/search traffic, switching the default + // branch could potentially cause outages if the ID space of the new branch is + // very different from the old one. + // + // More specifically: + // + // * PredictionService will only return product IDs from branch {newBranch}. + // * SearchService will only return product IDs from branch {newBranch} + // (if branch is not explicitly set). + // * UserEventService will only join events with products from branch + // {newBranch}. + rpc SetDefaultBranch(SetDefaultBranchRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" + body: "*" + }; + option (google.api.method_signature) = "catalog"; + } + + // Get which branch is currently default branch set by + // [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] + // method under a specified parent catalog. + rpc GetDefaultBranch(GetDefaultBranchRequest) + returns (GetDefaultBranchResponse) { + option (google.api.http) = { + get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + }; + option (google.api.method_signature) = "catalog"; + } +} + +// Request for +// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] +// method. +message ListCatalogsRequest { + // Required. The account resource name with an associated location. + // + // If the caller does not have permission to list + // [Catalog][google.cloud.retail.v2.Catalog]s under this location, regardless + // of whether or not this location exists, a PERMISSION_DENIED error is + // returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of [Catalog][google.cloud.retail.v2.Catalog]s to return. If + // unspecified, defaults to 50. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 2; + + // A page token + // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2.ListCatalogsResponse.next_page_token], + // received from a previous + // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; +} + +// Response for +// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] +// method. +message ListCatalogsResponse { + // All the customer's [Catalog][google.cloud.retail.v2.Catalog]s. + repeated Catalog catalogs = 1; + + // A token that can be sent as + // [ListCatalogsRequest.page_token][google.cloud.retail.v2.ListCatalogsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request for +// [CatalogService.UpdateCatalog][google.cloud.retail.v2.CatalogService.UpdateCatalog] +// method. +message UpdateCatalogRequest { + // Required. The [Catalog][google.cloud.retail.v2.Catalog] to update. + // + // If the caller does not have permission to update the + // [Catalog][google.cloud.retail.v2.Catalog], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the [Catalog][google.cloud.retail.v2.Catalog] to update does not exist, + // a NOT_FOUND error is returned. + Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Catalog][google.cloud.retail.v2.Catalog] to update. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message to set a specified branch as new default_branch. +message SetDefaultBranchRequest { + // Full resource name of the catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // The final component of the resource name of a branch. + // + // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // If there are no sufficient active products in the targeted branch and + // [force][google.cloud.retail.v2.SetDefaultBranchRequest.force] is not set, a + // FAILED_PRECONDITION error is returned. + string branch_id = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Some note on this request, this can be retrieved by + // [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch] + // before next valid default branch set occurs. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string note = 3; + + // If set to true, it permits switching to a branch with + // [branch_id][google.cloud.retail.v2.SetDefaultBranchRequest.branch_id] even + // if it has no sufficient active products. + bool force = 4; +} + +// Request message to show which branch is currently the default branch. +message GetDefaultBranchRequest { + // The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response message of +// [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch]. +message GetDefaultBranchResponse { + // Full resource name of the branch id currently set as default branch. + string branch = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // The time when this branch is set to default. + google.protobuf.Timestamp set_time = 2; + + // This corresponds to + // [SetDefaultBranchRequest.note][google.cloud.retail.v2.SetDefaultBranchRequest.note] + // field, when this branch was set as default. + string note = 3; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto new file mode 100644 index 00000000..386a9aa6 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto @@ -0,0 +1,491 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// An intended audience of the [Product][google.cloud.retail.v2.Product] for +// whom it's sold. +message Audience { + // The genders of the audience. Strongly encouraged to use the standard + // values: "male", "female", "unisex". + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [gender](https://support.google.com/merchants/answer/6324479). Schema.org + // property + // [Product.audience.suggestedGender](https://schema.org/suggestedGender). + repeated string genders = 1; + + // The age groups of the audience. Strongly encouraged to use the standard + // values: "newborn" (up to 3 months old), "infant" (3–12 months old), + // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically + // teens or older). + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [age_group](https://support.google.com/merchants/answer/6324463). + // Schema.org property + // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and + // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). + repeated string age_groups = 2; +} + +// The color information of a [Product][google.cloud.retail.v2.Product]. +message ColorInfo { + // The standard color families. Strongly recommended to use the following + // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", + // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and + // "Mixed". Normally it is expected to have only 1 color family. May consider + // using single "Mixed" instead of multiple values. + // + // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string color_families = 1; + + // The color display names, which may be different from standard color family + // names, such as the color aliases used in the website frontend. Normally + // it is expected to have only 1 color. May consider using single "Mixed" + // instead of multiple values. + // + // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string colors = 2; +} + +// A custom attribute that is not explicitly modeled in +// [Product][google.cloud.retail.v2.Product]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated double numbers = 2; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][] of the + // [Catalog][google.cloud.retail.v2.Catalog] is set to the deprecated + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level + // attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. + // + // Only set if type [text][google.cloud.retail.v2.CustomAttribute.text] is + // set. Otherwise, a INVALID_ARGUMENT error is returned. + optional bool searchable = 3 [deprecated = true]; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][] of the + // [Catalog][google.cloud.retail.v2.Catalog] is set to the deprecated + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level + // attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are indexed, so that they can be filtered, + // faceted or boosted in + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. + // + // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter], + // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] + // for more details. + optional bool indexable = 4 [deprecated = true]; +} + +// Fulfillment information, such as the store IDs for in-store pickup or region +// IDs for different shipping methods. +message FulfillmentInfo { + // The fulfillment type, including commonly used types (such as pickup in + // store and same day delivery), and custom types. Customers have to map + // custom types to their display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + string type = 1; + + // The IDs for this [type][google.cloud.retail.v2.FulfillmentInfo.type], such + // as the store IDs for + // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2.FulfillmentInfo.type] + // or the region IDs for + // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2.FulfillmentInfo.type]. + // + // A maximum of 3000 values are allowed. Each value must be a string with a + // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such + // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string place_ids = 2; +} + +// [Product][google.cloud.retail.v2.Product] image. Recommendations AI and +// Retail Search do not use product images to improve prediction and search +// results. However, product images can be returned in results, and are shown in +// prediction or search previews in the console. +message Image { + // Required. URI of the image. + // + // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Height of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 height = 2; + + // Width of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 width = 3; +} + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are set, then + // the lower bound is negative infinity. + // + // This field must be not larger than + // [max][google.cloud.retail.v2.Interval.max]. Otherwise, an INVALID_ARGUMENT + // error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are set, then + // the upper bound is positive infinity. + // + // This field must be not smaller than + // [min][google.cloud.retail.v2.Interval.min]. Otherwise, an INVALID_ARGUMENT + // error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// The price information of a [Product][google.cloud.retail.v2.Product]. +message PriceInfo { + // The price range of all + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. + message PriceRange { + // The inclusive + // [Product.pricing_info.price][google.cloud.retail.v2.PriceInfo.price] + // interval of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. + Interval price = 1; + + // The inclusive + // [Product.pricing_info.original_price][google.cloud.retail.v2.PriceInfo.original_price] + // internal of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. + Interval original_price = 2; + } + + // The 3-letter currency code defined in [ISO + // 4217](https://www.iso.org/iso-4217-currency-codes.html). + // + // If this field is an unrecognizable currency code, an INVALID_ARGUMENT + // error is returned. + // + // The [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s with the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] + // must share the same + // [currency_code][google.cloud.retail.v2.PriceInfo.currency_code]. Otherwise, + // a FAILED_PRECONDITION error is returned. + string currency_code = 1; + + // Price of the product. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). Schema.org + // property [Offer.price](https://schema.org/price). + float price = 2; + + // Price of the product without any discount. If zero, by default set to be + // the [price][google.cloud.retail.v2.PriceInfo.price]. If set, + // [original_price][google.cloud.retail.v2.PriceInfo.original_price] should be + // greater than or equal to [price][google.cloud.retail.v2.PriceInfo.price], + // otherwise an INVALID_ARGUMENT error is thrown. + float original_price = 3; + + // The costs associated with the sale of a particular product. Used for gross + // profit reporting. + // + // * Profit = [price][google.cloud.retail.v2.PriceInfo.price] - + // [cost][google.cloud.retail.v2.PriceInfo.cost] + // + // Google Merchant Center property + // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). + float cost = 4; + + // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] + // starts to be effective. This can be set as a future timestamp, and the + // [price][google.cloud.retail.v2.PriceInfo.price] is only used for search + // after + // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. + // If so, the + // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be + // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] + // is used before + // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. + // + // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_effective_time = 5; + + // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] + // stops to be effective. The [price][google.cloud.retail.v2.PriceInfo.price] + // is used for search before + // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. If + // this field is set, the + // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be + // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] + // is used after + // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. + // + // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_expire_time = 6; + + // Output only. The price range of all the child + // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s grouped together on the + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]. Only populated for + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. + // Do not set this field in API requests. + PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The rating of a [Product][google.cloud.retail.v2.Product]. +message Rating { + // The total number of ratings. This value is independent of the value of + // [rating_histogram][google.cloud.retail.v2.Rating.rating_histogram]. + // + // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 rating_count = 1; + + // The average rating of the [Product][google.cloud.retail.v2.Product]. + // + // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is + // returned. + float average_rating = 2; + + // List of rating counts per rating value (index = rating - 1). The list is + // empty if there is no rating. If the list is non-empty, its size is + // always 5. Otherwise, an INVALID_ARGUMENT error is returned. + // + // For example, [41, 14, 13, 47, 303]. It means that the + // [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 + // ratings with 2 star, and so on. + repeated int32 rating_histogram = 3; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. Don't set for anonymous users. + // + // Always use a hashed value for this ID. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded + // model quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string user_id = 1; + + // The end user's IP address. This field is used to extract location + // information for personalization. + // + // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 + // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This should not be set when: + // + // * setting + // [SearchRequest.user_info][google.cloud.retail.v2.SearchRequest.user_info]. + // * using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] + // is set. + string ip_address = 2; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][google.cloud.retail.v2.SearchResponse.sponsored_results]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] + // is set. + string user_agent = 3; + + // True if the request is made directly from the end user, in which case the + // [ip_address][google.cloud.retail.v2.UserInfo.ip_address] and + // [user_agent][google.cloud.retail.v2.UserInfo.user_agent] can be populated + // from the HTTP request. This flag should be set only if the API request is + // made directly from the end user such as a mobile app (and not if a gateway + // or a server is processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent]. + bool direct_user_request = 4; +} + +// The inventory information at a place (e.g. a store) identified +// by a place ID. +message LocalInventory { + // The place ID for the current set of inventory information. + string place_id = 1; + + // Product price and cost information. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 2; + + // Additional local inventory attributes, for example, store name, promotion + // tags, etc. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * At most 30 attributes are allowed. + // * The key must be a UTF-8 encoded string with a length limit of 32 + // characters. + // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, + // key0LikeThis or KEY_1_LIKE_THIS. + // * The attribute values must be of the same type (text or number). + // * Only 1 value is allowed for each attribute. + // * For text values, the length limit is 256 UTF-8 characters. + // * The attribute does not support search. The `searchable` field should be + // unset or set to false. + // * The max summed total bytes of custom attribute keys and values per + // product is 5MiB. + map attributes = 3; + + // Input only. Supported fulfillment types. Valid fulfillment type values + // include commonly used types (such as pickup in store and same day + // delivery), and custom types. Customers have to map custom types to their + // display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string fulfillment_types = 4 + [(google.api.field_behavior) = INPUT_ONLY]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto new file mode 100644 index 00000000..68306218 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto @@ -0,0 +1,205 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/import_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Auto-completion service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service CompletionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified prefix with keyword suggestions. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }; + } + + // Bulk import of processed completion dataset. + // + // Request processing is asynchronous. Partial updating is not supported. + // + // The operation is successfully finished only after the imported suggestions + // are indexed successfully and ready for serving. The process takes hours. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc ImportCompletionData(ImportCompletionDataRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.ImportCompletionDataResponse" + metadata_type: "google.cloud.retail.v2.ImportMetadata" + }; + } +} + +// Auto-complete parameters. +message CompleteQueryRequest { + // Required. Catalog for which the completion is performed. + // + // Full resource name of catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The query used to generate suggestions. + // + // The maximum number of allowed characters is 255. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required field. A unique identifier for tracking visitors. For example, + // this could be implemented with an HTTP cookie, which should be able to + // uniquely identify a visitor on a single device. This unique identifier + // should not change if the visitor logs in or out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 7; + + // The language filters applied to the output suggestions. If set, it should + // contain the language of the query. If not set, suggestions are returned + // without considering language restrictions. This is the BCP-47 language + // code, such as "en-US" or "sr-Latn". For more information, see [Tags for + // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + // number of language codes is 3. + repeated string language_codes = 3; + + // The device type context for completion suggestions. + // It is useful to apply different suggestions on different device types, e.g. + // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + // types. + // + // Supported formats: + // + // * `UNKNOWN_DEVICE_TYPE` + // + // * `DESKTOP` + // + // * `MOBILE` + // + // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + string device_type = 4; + + // Determines which dataset to use for fetching completion. "user-data" will + // use the imported dataset through + // [CompletionService.ImportCompletionData][google.cloud.retail.v2.CompletionService.ImportCompletionData]. + // "cloud-retail" will use the dataset generated by cloud retail based on user + // events. If leave empty, it will use the "user-data". + // + // Current supported values: + // + // * user-data + // + // * cloud-retail: + // This option requires enabling auto-learning function first. See + // [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + string dataset = 6; + + // Completion max suggestions. If left unset or set to 0, then will fallback + // to the configured value [CompletionConfig.max_suggestions][]. + // + // The maximum allowed max suggestions is 20. If it is set higher, it will be + // capped by 20. + int32 max_suggestions = 5; +} + +// Response of the auto-complete query. +message CompleteQueryResponse { + // Resource that represents completion results. + message CompletionResult { + // The suggestion for the query. + string suggestion = 1; + + // Custom attributes for the suggestion term. + // + // * For "user-data", the attributes are additional custom attributes + // ingested through BigQuery. + // + // * For "cloud-retail", the attributes are product attributes generated + // by Cloud Retail. This is an experimental feature. Contact Retail Search + // support team if you are interested in enabling it. + map attributes = 2; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Results of the matching suggestions. The result list is ordered and the + // first result is top suggestion. + repeated CompletionResult completion_results = 1; + + // A unique complete token. This should be included in the + // [UserEvent.completion_detail][google.cloud.retail.v2.UserEvent.completion_detail] + // for search events resulting from this completion, which enables accurate + // attribution of complete model performance. + string attribution_token = 2; + + // Matched recent searches of this user. The maximum number of recent searches + // is 10. This field is a restricted feature. Contact Retail Search support + // team if you are interested in enabling it. + // + // This feature is only available when + // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2.CompleteQueryRequest.visitor_id] + // field is set and [UserEvent][google.cloud.retail.v2.UserEvent] is imported. + // The recent searches satisfy the follow rules: + // + // * They are ordered from latest to oldest. + // + // * They are matched with + // [CompleteQueryRequest.query][google.cloud.retail.v2.CompleteQueryRequest.query] + // case insensitively. + // + // * They are transformed to lower cases. + // + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto new file mode 100644 index 00000000..cadec119 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto @@ -0,0 +1,401 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/cloud/retail/v2/user_event.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Google Cloud Storage location for input content. +// format. +message GcsSource { + // Required. Google Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. A request can + // contain at most 100 files, and each file can be up to 2 GB. See + // [Importing product + // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) + // for the expected file format and setup instructions. + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] + // per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2.UserEvent] per line. + // * `user_event_ga360`: Using + // https://support.google.com/analytics/answer/3437719. + // + // Supported values for control imports: + // + // * 'control' (default): One JSON [Control][] per line. + // + // Supported values for catalog attribute imports: + // + // * 'catalog_attribute' (default): One CSV [CatalogAttribute][] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + google.type.Date partition_date = 6; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 5; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 3; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] + // per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2.UserEvent] per line. + // * `user_event_ga360`: + // The schema is available here: + // https://support.google.com/analytics/answer/3437719. + // * `user_event_ga4`: This feature is in private preview. Please contact the + // support team for importing Google Analytics 4 events. + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for auto-completion imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + string data_schema = 4; +} + +// The inline source for the input config for ImportProducts method. +message ProductInlineSource { + // Required. A list of products to update/create. Each product must have a + // valid [Product.id][google.cloud.retail.v2.Product.id]. Recommended max of + // 100 items. + repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The inline source for the input config for ImportUserEvents method. +message UserEventInlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configuration of destination for Import related errors. +message ImportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors will be written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for Import methods. +message ImportProductsRequest { + // Indicates how imported products are reconciled with the existing products + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new products or updates existing products. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire product dataset. Existing + // products may be deleted if they are not present in the source location. + // + // Can only be set while using + // [BigQuerySource][google.cloud.retail.v2.BigQuerySource]. And the BigQuery + // dataset must be created in the data location "us (multiple regions in + // United States)", otherwise a PERMISSION_DENIED error is thrown. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + FULL = 2; + } + + // Required. + // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + // + // If no updateMask is specified, requires products.create permission. + // If updateMask is specified, requires products.update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Deprecated. This field has no effect. + string request_id = 6 [deprecated = true]; + + // Required. The desired input location of the data. + ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. + ImportErrorsConfig errors_config = 3; + + // Indicates which fields in the provided imported 'products' to update. If + // not set, will by default update all fields. + google.protobuf.FieldMask update_mask = 4; + + // The mode of reconciliation between existing products and the products to be + // imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 5; + + // Full Pub/Sub topic name for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + // to be within the same project as + // [ImportProductsRequest.parent][google.cloud.retail.v2.ImportProductsRequest.parent]. + // Make sure that both + // `cloud-retail-customer-data-access@system.gserviceaccount.com` and + // `service-@gcp-sa-retail.iam.gserviceaccount.com` + // have the `pubsub.topics.publish` IAM permission on the topic. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + string notification_pubsub_topic = 7; +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // Required. `projects/1234/locations/global/catalogs/default_catalog` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + UserEventInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorsConfig errors_config = 3; +} + +// Request message for ImportCompletionData methods. +message ImportCompletionDataRequest { + // Required. The catalog which the suggestions dataset belongs to. + // + // Format: `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + CompletionDataInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 3; +} + +// The input config source for products. +message ProductInputConfig { + // Required. The source of the input. + oneof source { + // The Inline source for the input content for products. + ProductInlineSource product_inline_source = 1; + + // Google Cloud Storage location for the input content. + GcsSource gcs_source = 2; + + // BigQuery input source. + BigQuerySource big_query_source = 3; + } +} + +// The input config source for user events. +message UserEventInputConfig { + // The source of the input. + oneof source { + // Required. The Inline source for the input content for UserEvents. + UserEventInlineSource user_event_inline_source = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Google Cloud Storage location for the input content. + GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource big_query_source = 3 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// The input config source for completion data. +message CompletionDataInputConfig { + // The source of the input. + // + // Supported + // [BigQuerySource.data_schema][google.cloud.retail.v2.BigQuerySource.data_schema] + // values for suggestions imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + oneof source { + // Required. BigQuery input source. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + BigQuerySource big_query_source = 1 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// Metadata related to the progress of the Import operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ImportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; + + // Deprecated. This field is never set. + string request_id = 5 [deprecated = true]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; +} + +// Response of the +// [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest]. If the +// long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorsConfig errors_config = 2; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorsConfig errors_config = 2; + + // Aggregated statistics of user event import status. + UserEventImportSummary import_summary = 3; +} + +// A summary of import result. The UserEventImportSummary summarizes +// the import status for user events. +message UserEventImportSummary { + // Count of user events imported with complete existing catalog information. + int64 joined_events_count = 1; + + // Count of user events imported, but with catalog information not found + // in the imported catalog. + int64 unjoined_events_count = 2; +} + +// Response of the +// [ImportCompletionDataRequest][google.cloud.retail.v2.ImportCompletionDataRequest]. +// If the long running operation is done, this message is returned by the +// google.longrunning.Operations.response field if the operation is successful. +message ImportCompletionDataResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto new file mode 100644 index 00000000..f1f1b4e1 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto @@ -0,0 +1,204 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "PredictionServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for making recommendation prediction. +service PredictionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation prediction. + rpc Predict(PredictRequest) returns (PredictResponse) { + option (google.api.http) = { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" + body: "*" + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} + // The ID of the Recommendations AI placement. Before you can request + // predictions from your model, you must create at least one placement for it. + // For more information, see [Managing + // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + // + // The full list of available placements can be seen at + // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the predict request. Note that this user event detail + // won't be ingested to userEvent logs. Thus, a separate userEvent write + // request is required for event logging. + // + // Don't set + // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id] or + // [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id] to the same + // fixed ID for different users. If you are trying to receive non-personalized + // recommendations (not recommended; this can negatively impact model + // performance), instead set + // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id] to a + // random unique ID and leave + // [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id] unset. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return per page. Set this property + // to the number of prediction results needed. If zero, the service will + // choose a reasonable default. The maximum allowed value is 100. Values + // above 100 will be coerced to 100. + int32 page_size = 3; + + // The previous PredictResponse.next_page_token. + string page_token = 4; + + // Filter for restricting prediction results with a length limit of 5,000 + // characters. Accepts values for tags and the `filterOutOfStockItems` flag. + // + // * Tag expressions. Restricts predictions to products that match all of the + // specified tags. Boolean operators `OR` and `NOT` are supported if the + // expression is enclosed in parentheses, and must be separated from the + // tag values by a space. `-"tagA"` is also supported and is equivalent to + // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + // with a size limit of 1,000 characters. + // + // Note: "Recently viewed" models don't support tag filtering at the + // moment. + // + // * filterOutOfStockItems. Restricts predictions to products that do not + // have a + // stockState value of OUT_OF_STOCK. + // + // Examples: + // + // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + // * filterOutOfStockItems tag=(-"promotional") + // * filterOutOfStockItems + // + // If your filter blocks all prediction results, the API will return generic + // (unfiltered) popular products. If you only want results strictly matching + // the filters, set `strictFiltering` to True in `PredictRequest.params` to + // receive empty results instead. + // Note that the API will never return items with storageStatus of "EXPIRED" + // or "DELETED" regardless of filter choices. + string filter = 5; + + // Use validate only mode for this prediction query. If set to true, a + // dummy model will be used that returns arbitrary products. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 6; + + // Additional domain specific parameters for the predictions. + // + // Allowed values: + // + // * `returnProduct`: Boolean. If set to true, the associated product + // object will be returned in the `results.metadata` field in the + // prediction response. + // * `returnScore`: Boolean. If set to true, the prediction 'score' + // corresponding to each returned product will be set in the + // `results.metadata` field in the prediction response. The given + // 'score' indicates the probability of an product being clicked/purchased + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular products instead of empty if + // your filter blocks all prediction results. + // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-price-reranking', 'low-price-reranking', + // 'medium-price-reranking', 'high-price-reranking'}. This gives + // request-level control and adjusts prediction results based on product + // price. + // * `diversityLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-diversity', 'low-diversity', + // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + // request-level control and adjusts prediction results based on product + // category. + map params = 7; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters and cannot be empty. Values can be empty and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 8; +} + +// Response message for predict method. +message PredictResponse { + // PredictionResult represents the recommendation prediction results. + message PredictionResult { + // ID of the recommended product + string id = 1; + + // Additional product metadata / annotations. + // + // Possible values: + // + // * `product`: JSON representation of the product. Is set if + // `returnProduct` is set to true in `PredictRequest.params`. + // * `score`: Prediction score in double value. Is set if + // `returnScore` is set to true in `PredictRequest.params`. + map metadata = 2; + } + + // A list of recommended products. The order represents the ranking (from the + // most relevant product to the least). + repeated PredictionResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this + // recommendation, which enables accurate attribution of recommendation model + // performance. + string attribution_token = 2; + + // IDs of products in the request that were missing from the inventory. + repeated string missing_ids = 3; + + // True if the validateOnly property was set in the request. + bool validate_only = 4; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto new file mode 100644 index 00000000..43443295 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto @@ -0,0 +1,558 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/promotion.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" +}; + +// Product captures all metadata information of items to be recommended or +// searched. +message Product { + option (google.api.resource) = { + type: "retail.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }; + + // The type of this product. + enum Type { + // Default value. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] + // if unset. + TYPE_UNSPECIFIED = 0; + + // The primary type. + // + // As the primary unit for predicting, indexing and search serving, a + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] is grouped with multiple + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. + PRIMARY = 1; + + // The variant type. + // + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s usually share some common + // attributes on the same + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s, but they have variant + // attributes like different colors, sizes and prices, etc. + VARIANT = 2; + + // The collection type. Collection products are bundled + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s or + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s that are sold together, such + // as a jewelry set with necklaces, earrings and rings, etc. + COLLECTION = 3; + } + + // Product availability. If this field is unspecified, the product is + // assumed to be in stock. + enum Availability { + // Default product availability. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK] + // if unset. + AVAILABILITY_UNSPECIFIED = 0; + + // Product in stock. + IN_STOCK = 1; + + // Product out of stock. + OUT_OF_STOCK = 2; + + // Product that is in pre-order state. + PREORDER = 3; + + // Product that is back-ordered (i.e. temporarily out of stock). + BACKORDER = 4; + } + + oneof expiration { + // The timestamp when this product becomes unavailable for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // If it is set, the [Product][google.cloud.retail.v2.Product] is not + // available for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after + // [expire_time][google.cloud.retail.v2.Product.expire_time]. However, the + // product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // [expire_time][google.cloud.retail.v2.Product.expire_time] must be later + // than [available_time][google.cloud.retail.v2.Product.available_time] and + // [publish_time][google.cloud.retail.v2.Product.publish_time], otherwise an + // INVALID_ARGUMENT error is thrown. + // + // Corresponding properties: Google Merchant Center property + // [expiration_date](https://support.google.com/merchants/answer/6324499). + google.protobuf.Timestamp expire_time = 16; + + // Input only. The TTL (time to live) of the product. + // + // If it is set, it must be a non-negative value, and + // [expire_time][google.cloud.retail.v2.Product.expire_time] is set as + // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. The + // derived [expire_time][google.cloud.retail.v2.Product.expire_time] is + // returned in the output and [ttl][google.cloud.retail.v2.Product.ttl] is + // left blank when retrieving the [Product][google.cloud.retail.v2.Product]. + // + // If it is set, the product is not available for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after + // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. + // However, the product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + google.protobuf.Duration ttl = 17 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Immutable. Full resource name of the product, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. [Product][google.cloud.retail.v2.Product] identifier, which is + // the final component of [name][google.cloud.retail.v2.Product.name]. For + // example, this field is "id_1", if + // [name][google.cloud.retail.v2.Product.name] is + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [id](https://support.google.com/merchants/answer/6324405). Schema.org + // property [Product.sku](https://schema.org/sku). + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The type of the product. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] + // if unset. + Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Variant group identifier. Must be an + // [id][google.cloud.retail.v2.Product.id], with the same parent branch with + // this product. Otherwise, an error is thrown. + // + // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s, this field can only be empty or + // set to the same value as [id][google.cloud.retail.v2.Product.id]. + // + // For VARIANT [Product][google.cloud.retail.v2.Product]s, this field cannot + // be empty. A maximum of 2,000 products are allowed to share the same + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]. Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // Corresponding properties: Google Merchant Center property + // [item_group_id](https://support.google.com/merchants/answer/6324507). + // Schema.org property + // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). + string primary_product_id = 4; + + // The [id][google.cloud.retail.v2.Product.id] of the collection members when + // [type][google.cloud.retail.v2.Product.type] is + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]. + // + // Non-existent product ids are allowed. + // The [type][google.cloud.retail.v2.Product.type] of the members must be + // either [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] or + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] otherwise and + // INVALID_ARGUMENT error is thrown. Should not set it for other types. A + // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is + // return. + repeated string collection_member_ids = 5; + + // The Global Trade Item Number (GTIN) of the product. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Corresponding properties: Google Merchant Center property + // [gtin](https://support.google.com/merchants/answer/6324461). + // Schema.org property + // [Product.isbn](https://schema.org/isbn), + // [Product.gtin8](https://schema.org/gtin8), + // [Product.gtin12](https://schema.org/gtin12), + // [Product.gtin13](https://schema.org/gtin13), or + // [Product.gtin14](https://schema.org/gtin14). + // + // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. + string gtin = 6; + + // Product categories. This field is repeated for supporting one product + // belonging to several parallel categories. Strongly recommended using the + // full path for better search / recommendation quality. + // + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // For example, if a shoes product belongs to both + // ["Shoes & Accessories" -> "Shoes"] and + // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be + // represented as: + // + // "categories": [ + // "Shoes & Accessories > Shoes", + // "Sports & Fitness > Athletic Clothing > Shoes" + // ] + // + // Must be set for [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] otherwise an INVALID_ARGUMENT + // error is returned. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2.Product]. Empty values are not allowed. + // Each value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [google_product_category][mc_google_product_category]. Schema.org property + // [Product.category] (https://schema.org/category). + // + // [mc_google_product_category]: + // https://support.google.com/merchants/answer/6324436 + repeated string categories = 7; + + // Required. Product title. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [title](https://support.google.com/merchants/answer/6324415). Schema.org + // property [Product.name](https://schema.org/name). + string title = 8 [(google.api.field_behavior) = REQUIRED]; + + // The brands of the product. + // + // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded + // string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [brand](https://support.google.com/merchants/answer/6324351). Schema.org + // property [Product.brand](https://schema.org/brand). + repeated string brands = 9; + + // Product description. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [description](https://support.google.com/merchants/answer/6324468). + // Schema.org property [Product.description](https://schema.org/description). + string description = 10; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // + // For product prediction, this field is ignored and the model automatically + // detects the text language. The [Product][google.cloud.retail.v2.Product] + // can include text in different languages, but duplicating + // [Product][google.cloud.retail.v2.Product]s to provide text in multiple + // languages can result in degraded model performance. + // + // For product search this field is in use. It defaults to "en-US" if unset. + string language_code = 11; + + // Highly encouraged. Extra product attributes to be included. For example, + // for products, this could include the store name, vendor, style, color, etc. + // These are very strong signals for recommendation model, thus we highly + // recommend providing the attributes here. + // + // Features that can take on one of a limited number of possible values. Two + // types of features can be set are: + // + // Textual features. some examples would be the brand/maker of a product, or + // country of a customer. Numerical features. Some examples would be the + // height/weight of a product, or age of a customer. + // + // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, + // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} + // }`. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * Max entries count: 200. + // * The key must be a UTF-8 encoded string with a length limit of 128 + // characters. + // * For indexable attribute, the key must match the pattern: + // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or + // `KEY_1_LIKE_THIS`. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a non-empty UTF-8 encoded string with a + // length limit of 256 characters. + // * For number attributes, at most 400 values are allowed. + map attributes = 12; + + // Custom tags associated with the product. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2.Product]. This value must be a UTF-8 + // encoded string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This tag can be used for filtering recommendation results by passing the + // tag as part of the + // [PredictRequest.filter][google.cloud.retail.v2.PredictRequest.filter]. + // + // Corresponding properties: Google Merchant Center property + // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). + repeated string tags = 13; + + // Product price and cost information. + // + // Corresponding properties: Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 14; + + // The rating of this product. + Rating rating = 15; + + // The timestamp when this [Product][google.cloud.retail.v2.Product] becomes + // available for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + google.protobuf.Timestamp available_time = 18; + + // The online availability of the [Product][google.cloud.retail.v2.Product]. + // Default to + // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK]. + // + // Corresponding properties: Google Merchant Center property + // [availability](https://support.google.com/merchants/answer/6324448). + // Schema.org property [Offer.availability](https://schema.org/availability). + Availability availability = 19; + + // The available quantity of the item. + google.protobuf.Int32Value available_quantity = 20; + + // Fulfillment information, such as the store IDs for in-store pickup or + // region IDs for different shipping methods. + // + // All the elements must have distinct + // [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type]. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated FulfillmentInfo fulfillment_info = 21; + + // Canonical URL directly linking to the product detail page. + // + // It is strongly recommended to provide a valid uri for the product, + // otherwise the service performance could be significantly degraded. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [link](https://support.google.com/merchants/answer/6324416). Schema.org + // property [Offer.url](https://schema.org/url). + string uri = 22; + + // Product images for the product. We highly recommend putting the main + // image first. + // + // A maximum of 300 images are allowed. + // + // Corresponding properties: Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + repeated Image images = 23; + + // The target group associated with a given audience (e.g. male, veterans, + // car owners, musicians, etc.) of the product. + Audience audience = 24; + + // The color of the product. + // + // Corresponding properties: Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + ColorInfo color_info = 25; + + // The size of the product. To represent different size systems or size types, + // consider using this format: [[[size_system:]size_type:]size_value]. + // + // For example, in "US:MENS:M", "US" represents size system; "MENS" represents + // size type; "M" represents size value. In "GIRLS:27", size system is empty; + // "GIRLS" represents size type; "27" represents size value. In "32 inches", + // both size system and size type are empty, while size value is "32 inches". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [size](https://support.google.com/merchants/answer/6324492), + // [size_type](https://support.google.com/merchants/answer/6324497), and + // [size_system](https://support.google.com/merchants/answer/6324502). + // Schema.org property [Product.size](https://schema.org/size). + repeated string sizes = 26; + + // The material of the product. For example, "leather", "wooden". + // + // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 200 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [material](https://support.google.com/merchants/answer/6324410). Schema.org + // property [Product.material](https://schema.org/material). + repeated string materials = 27; + + // The pattern or graphic print of the product. For example, "striped", "polka + // dot", "paisley". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org + // property [Product.pattern](https://schema.org/pattern). + repeated string patterns = 28; + + // The condition of the product. Strongly encouraged to use the standard + // values: "new", "refurbished", "used". + // + // A maximum of 1 value is allowed per + // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [condition](https://support.google.com/merchants/answer/6324469). + // Schema.org property + // [Offer.itemCondition](https://schema.org/itemCondition). + repeated string conditions = 29; + + // The promotions applied to the product. A maximum of 10 values are allowed + // per [Product][google.cloud.retail.v2.Product]. Only + // [Promotion.promotion_id][google.cloud.retail.v2.Promotion.promotion_id] + // will be used, other fields will be ignored if set. + repeated Promotion promotions = 34; + + // The timestamp when the product is published by the retailer for the first + // time, which indicates the freshness of the products. Note that this field + // is different from + // [available_time][google.cloud.retail.v2.Product.available_time], given it + // purely describes product freshness regardless of when it is available on + // search and recommendation. + google.protobuf.Timestamp publish_time = 33; + + // Indicates which fields in the [Product][google.cloud.retail.v2.Product]s + // are returned in [SearchResponse][google.cloud.retail.v2.SearchResponse]. + // + // Supported fields for all [type][google.cloud.retail.v2.Product.type]s: + // + // * [audience][google.cloud.retail.v2.Product.audience] + // * [availability][google.cloud.retail.v2.Product.availability] + // * [brands][google.cloud.retail.v2.Product.brands] + // * [color_info][google.cloud.retail.v2.Product.color_info] + // * [conditions][google.cloud.retail.v2.Product.conditions] + // * [gtin][google.cloud.retail.v2.Product.gtin] + // * [materials][google.cloud.retail.v2.Product.materials] + // * [name][google.cloud.retail.v2.Product.name] + // * [patterns][google.cloud.retail.v2.Product.patterns] + // * [price_info][google.cloud.retail.v2.Product.price_info] + // * [rating][google.cloud.retail.v2.Product.rating] + // * [sizes][google.cloud.retail.v2.Product.sizes] + // * [title][google.cloud.retail.v2.Product.title] + // * [uri][google.cloud.retail.v2.Product.uri] + // + // Supported fields only for + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]: + // + // * [categories][google.cloud.retail.v2.Product.categories] + // * [description][google.cloud.retail.v2.Product.description] + // * [images][google.cloud.retail.v2.Product.images] + // + // Supported fields only for + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]: + // + // * Only the first image in [images][google.cloud.retail.v2.Product.images] + // + // To mark [attributes][google.cloud.retail.v2.Product.attributes] as + // retrievable, include paths of the form "attributes.key" where "key" is the + // key of a custom attribute, as specified in + // [attributes][google.cloud.retail.v2.Product.attributes]. + // + // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], the + // following fields are always returned in + // [SearchResponse][google.cloud.retail.v2.SearchResponse] by default: + // + // * [name][google.cloud.retail.v2.Product.name] + // + // For [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT], the + // following fields are always returned in by default: + // + // * [name][google.cloud.retail.v2.Product.name] + // * [color_info][google.cloud.retail.v2.Product.color_info] + // + // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2.SearchResponse] can increase + // response payload size and serving latency. + google.protobuf.FieldMask retrievable_fields = 30; + + // Output only. Product variants grouped together on primary product which + // share similar product attributes. It's automatically grouped by + // [primary_product_id][google.cloud.retail.v2.Product.primary_product_id] for + // all the product variants. Only populated for + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. + // Do not set this field in API requests. + repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto new file mode 100644 index 00000000..ba8d8d18 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto @@ -0,0 +1,838 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/import_config.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for ingesting [Product][google.cloud.retail.v2.Product] information +// of the customer's website. +service ProductService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Product][google.cloud.retail.v2.Product]. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Gets a [Product][google.cloud.retail.v2.Product]. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Product][google.cloud.retail.v2.Product]s. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a [Product][google.cloud.retail.v2.Product]. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v2/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Deletes a [Product][google.cloud.retail.v2.Product]. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. + // + // Request processing may be synchronous. + // Non-existing items are created. + // + // Note that it is possible for a subset of the + // [Product][google.cloud.retail.v2.Product]s to be successfully updated. + rpc ImportProducts(ImportProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.ImportProductsResponse" + metadata_type: "google.cloud.retail.v2.ImportMetadata" + }; + } + + // Updates inventory information for a + // [Product][google.cloud.retail.v2.Product] while respecting the last update + // timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, updates are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // When inventory is updated with + // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and + // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the + // specified inventory field value(s) will overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update time for the specified inventory fields will be overwritten to the + // time of the + // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or + // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + // request. + // + // If no inventory fields are set in + // [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], + // then any pre-existing inventory information for this product will be used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], + // then any existing inventory information will be preserved. + // + // Pre-existing inventory information can only be updated with + // [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], + // and + // [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" + body: "*" + }; + option (google.api.method_signature) = "inventory,set_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.SetInventoryResponse" + metadata_type: "google.cloud.retail.v2.SetInventoryMetadata" + }; + } + + // Incrementally adds place IDs to + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the added place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.AddFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2.AddFulfillmentPlacesMetadata" + }; + } + + // Incrementally removes place IDs from a + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the removed place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata" + }; + } + + // Updates local inventory information for a + // [Product][google.cloud.retail.v2.Product] at a list of places, while + // respecting the last update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // inventory information. If the request is valid, the update will be enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and + // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no + // effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddLocalInventories(AddLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.AddLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2.AddLocalInventoriesMetadata" + }; + } + + // Remove local inventory information for a + // [Product][google.cloud.retail.v2.Product] at a list of places at a removal + // timestamp. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, removals are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and + // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no + // effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.RemoveLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2.RemoveLocalInventoriesMetadata" + }; + } +} + +// Request message for [CreateProduct][] method. +message CreateProductRequest { + // Required. The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The [Product][google.cloud.retail.v2.Product] to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the [Product][google.cloud.retail.v2.Product], + // which will become the final component of the + // [Product.name][google.cloud.retail.v2.Product.name]. + // + // If the caller does not have permission to create the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // This field must be unique among all + // [Product][google.cloud.retail.v2.Product]s with the same + // [parent][google.cloud.retail.v2.CreateProductRequest.parent]. Otherwise, an + // ALREADY_EXISTS error is returned. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string product_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [GetProduct][] method. +message GetProductRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the requested [Product][google.cloud.retail.v2.Product] does not exist, + // a NOT_FOUND error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for [UpdateProduct][] method. +message UpdateProductRequest { + // Required. The product to update/create. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2.Product] to update does not exist + // and + // [allow_missing][google.cloud.retail.v2.UpdateProductRequest.allow_missing] + // is not set, a NOT_FOUND error is returned. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Product][google.cloud.retail.v2.Product] to update. The immutable and + // output only fields are NOT supported. If not set, all supported fields (the + // fields that are neither immutable nor output only) are updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + // + // The attribute key can be updated by setting the mask path as + // "attributes.${key_name}". If a key name is present in the mask but not in + // the patching product from the request, this key will be deleted after the + // update. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, a new [Product][google.cloud.retail.v2.Product] will be created. In + // this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for [DeleteProduct][] method. +message DeleteProductRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to delete the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2.Product] to delete does not exist, + // a NOT_FOUND error is returned. + // + // The [Product][google.cloud.retail.v2.Product] to delete can neither be a + // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2.Product] member nor a + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] with more than one + // [variants][google.cloud.retail.v2.Product.Type.VARIANT]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // All inventory information for the named + // [Product][google.cloud.retail.v2.Product] will be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] +// method. +message ListProductsRequest { + // Required. The parent branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use + // `default_branch` as the branch ID, to list products under the default + // branch. + // + // If the caller does not have permission to list + // [Product][google.cloud.retail.v2.Product]s under this branch, regardless of + // whether or not this branch exists, a PERMISSION_DENIED error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If + // unspecified, defaults to 100. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT error is returned. + int32 page_size = 2; + + // A page token + // [ListProductsResponse.next_page_token][google.cloud.retail.v2.ListProductsResponse.next_page_token], + // received from a previous + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; + + // A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2.ListProductsRequest.filter] is unset. + // * List [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s sharing the same + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]. For example: + // `primary_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2.Product]s bundled in a + // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2.Product]. + // For example: + // `collection_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2.Product]s with a partibular type. + // For example: + // `type = "PRIMARY"` + // `type = "VARIANT"` + // `type = "COLLECTION"` + // + // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + // + // If the specified + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] or + // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2.Product] does not exist, a NOT_FOUND error + // is returned. + string filter = 4; + + // The fields of [Product][google.cloud.retail.v2.Product] to return in the + // responses. If not set or empty, the following fields are returned: + // + // * [Product.name][google.cloud.retail.v2.Product.name] + // * [Product.id][google.cloud.retail.v2.Product.id] + // * [Product.title][google.cloud.retail.v2.Product.title] + // * [Product.uri][google.cloud.retail.v2.Product.uri] + // * [Product.images][google.cloud.retail.v2.Product.images] + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // * [Product.brands][google.cloud.retail.v2.Product.brands] + // + // If "*" is provided, all fields are returned. + // [Product.name][google.cloud.retail.v2.Product.name] is always returned no + // matter what mask is set. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask read_mask = 5; +} + +// Response message for +// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] +// method. +message ListProductsResponse { + // The [Product][google.cloud.retail.v2.Product]s. + repeated Product products = 1; + + // A token that can be sent as + // [ListProductsRequest.page_token][google.cloud.retail.v2.ListProductsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for [SetInventory][] method. +message SetInventoryRequest { + // Required. The inventory information to update. The allowable fields to + // update are: + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // * [Product.availability][google.cloud.retail.v2.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] + // The updated inventory fields must be specified in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask]. + // + // If [SetInventoryRequest.inventory.name][] is empty or invalid, an + // INVALID_ARGUMENT error is returned. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2.Product] named in + // [Product.name][google.cloud.retail.v2.Product.name], regardless of whether + // or not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2.Product] to update does not have + // existing inventory information, the provided inventory information will be + // inserted. + // + // If the [Product][google.cloud.retail.v2.Product] to update has existing + // inventory information, the provided inventory information will be merged + // while respecting the last update time for each inventory field, using the + // provided or default value for + // [SetInventoryRequest.set_time][google.cloud.retail.v2.SetInventoryRequest.set_time]. + // + // The caller can replace place IDs for a subset of fulfillment types in the + // following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types and corresponding place IDs + // to update in [SetInventoryRequest.inventory.fulfillment_info][] + // + // The caller can clear all place IDs from a subset of fulfillment types in + // the following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types to clear in + // [SetInventoryRequest.inventory.fulfillment_info][] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] + // + // The last update time is recorded for the following inventory fields: + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // * [Product.availability][google.cloud.retail.v2.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] + // + // If a full overwrite of inventory information while ignoring timestamps is + // needed, [UpdateProduct][] should be invoked instead. + Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided + // [Product][google.cloud.retail.v2.Product] to update. + // + // At least one field must be provided. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask set_mask = 2; + + // The time when the request is issued, used to prevent + // out-of-order updates on inventory fields with the last update time + // recorded. If not provided, the internal system time will be used. + google.protobuf.Timestamp set_time = 3; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] with name + // [Product.name][google.cloud.retail.v2.Product.name] is not found, the + // inventory update will still be processed and retained for at most 1 day + // until the [Product][google.cloud.retail.v2.Product] is created. If set to + // false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 4; +} + +// Metadata related to the progress of the SetInventory operation. +// Currently empty because there is no meaningful metadata populated from the +// [SetInventory][] method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the [SetInventory][] +// method. +message SetInventoryResponse {} + +// Request message for +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type], such as + // the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery" to be added for this + // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type]. Duplicate + // IDs will be automatically ignored. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // If the total number of place IDs exceeds 2000 for this + // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type] after + // adding, then the update will be rejected. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the fulfillment information will still be processed and retained for + // at most 1 day and processed once the + // [Product][google.cloud.retail.v2.Product] is created. If set to false, a + // NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the AddFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesMetadata {} + +// Response of the AddFulfillmentPlacesRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of inventory information at difference places. Each place + // is identified by its place ID. At most 3000 inventories are allowed per + // request. + repeated LocalInventory local_inventories = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided list of + // [LocalInventory][google.cloud.retail.v2.LocalInventory] to update. The + // field is updated to the provided value. + // + // If a field is set while the place does not have a previous local inventory, + // the local inventory at that store is created. + // + // If a field is set while the value of that field is not provided, the + // original field value, if it exists, is deleted. + // + // If the mask is not set or set with empty paths, all inventory fields will + // be updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask add_mask = 4; + + // The time when the inventory updates are issued. Used to prevent + // out-of-order updates on local inventory fields. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the local inventory will still be processed and retained for at most + // 1 day and processed once the [Product][google.cloud.retail.v2.Product] is + // created. If set to false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 6; +} + +// Metadata related to the progress of the AddLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesMetadata {} + +// Response of the +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesResponse {} + +// Request message for [RemoveLocalInventories][] method. +message RemoveLocalInventoriesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of place IDs to have their inventory deleted. + // At most 3000 place IDs are allowed per request. + repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; + + // The time when the inventory deletions are issued. Used to prevent + // out-of-order updates and deletions on local inventory fields. If not + // provided, the internal system time will be used. + google.protobuf.Timestamp remove_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the local inventory removal request will still be processed and + // retained for at most 1 day and processed once the + // [Product][google.cloud.retail.v2.Product] is created. If set to false, a + // NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 3; +} + +// Metadata related to the progress of the RemoveLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveLocalInventories][] method. +message RemoveLocalInventoriesMetadata {} + +// Response of the [RemoveLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [RemoveLocalInventories][] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to + // [Product.fulfillment_info.type][google.cloud.retail.v2.FulfillmentInfo.type]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type], such as + // the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery", to be removed for this + // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type]. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp remove_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the fulfillment information will still be processed and retained for + // at most 1 day and processed once the + // [Product][google.cloud.retail.v2.Product] is created. If set to false, a + // NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the RemoveFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the [RemoveFulfillmentPlaces][] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto new file mode 100644 index 00000000..9ba32347 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto @@ -0,0 +1,40 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "PromotionProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Promotion information. +message Promotion { + // ID of the promotion. For example, "free gift". + // + // The value must be a UTF-8 encoded string with a length limit of 128 + // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, + // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Google Merchant Center property + // [promotion](https://support.google.com/merchants/answer/7050148). + string promotion_id = 1; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto new file mode 100644 index 00000000..cb510745 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto @@ -0,0 +1,82 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Metadata related to the progress of the Purge operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeMetadata {} + +// Request message for PurgeUserEvents method. +message PurgeUserEventsRequest { + // Required. The resource name of the catalog under which the events are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The filter string to specify the events to be deleted with a + // length limit of 5,000 characters. Empty string filter is not allowed. The + // eligible fields for filtering are: + // + // * `eventType`: Double quoted + // [UserEvent.event_type][google.cloud.retail.v2.UserEvent.event_type] string. + // * `eventTime`: in ISO 8601 "zulu" format. + // * `visitorId`: Double quoted string. Specifying this will delete all + // events associated with a visitor. + // * `userId`: Double quoted string. Specifying this will delete all events + // associated with a user. + // + // Examples: + // + // * Deleting all events in a time range: + // `eventTime > "2012-04-23T18:25:43.511Z" + // eventTime < "2012-04-23T18:30:43.511Z"` + // * Deleting specific eventType in time range: + // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + // * Deleting all events for a specific visitor: + // `visitorId = "visitor1024"` + // + // The filtering fields are assumed to have an implicit AND. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any user events. + bool force = 3; +} + +// Response of the PurgeUserEventsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeUserEventsResponse { + // The total count of events purged as a result of the operation. + int64 purged_events_count = 1; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto new file mode 100644 index 00000000..82242742 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto @@ -0,0 +1,854 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service SearchService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" + body: "*" + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Product][google.cloud.retail.v2.Product] object, over which the facet + // values are computed. Facet key is case-sensitive. + // + // Allowed facet keys when + // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] + // is not specified: + // + // * textual_field = + // * "brands" + // * "categories" + // * "genders" + // * "ageGroups" + // * "availability" + // * "colorFamilies" + // * "colors" + // * "sizes" + // * "materials" + // * "patterns" + // * "conditions" + // * "attributes.key" + // * "pickupInStore" + // * "shipToStore" + // * "sameDayDelivery" + // * "nextDayDelivery" + // * "customFulfillment1" + // * "customFulfillment2" + // * "customFulfillment3" + // * "customFulfillment4" + // * "customFulfillment5" + // * "inventory(place_id,attributes.key)" + // + // * numerical_field = + // * "price" + // * "discount" + // * "rating" + // * "ratingCount" + // * "attributes.key" + // * "inventory(place_id,price)" + // * "inventory(place_id,original_price)" + // * "inventory(place_id,attributes.key)" + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. For example, when using + // "pickupInStore" as key and set restricted values to + // ["store123", "store456"], only facets for "store123" and "store456" are + // returned. Only supported on predefined textual fields, custom textual + // attributes and fulfillments. Maximum is 20. + // + // Must be set for the fulfillment facet keys: + // + // * pickupInStore + // + // * shipToStore + // + // * sameDayDelivery + // + // * nextDayDelivery + // + // * customFulfillment1 + // + // * customFulfillment2 + // + // * customFulfillment3 + // + // * customFulfillment4 + // + // * customFulfillment5 + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the + // "categories" facet will give only "Women > Shoe" and "Women > Dress". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 8; + + // Only get facet values that contains the given strings. For example, + // suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the + // "categories" facet will give only "Women > Shoe" and "Men > Shoe". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 9; + + // The order in which [Facet.values][] are returned. + // + // Allowed values are: + // + // * "count desc", which means order by [Facet.FacetValue.count][] + // descending. + // + // * "value desc", which means order by [Facet.FacetValue.value][] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.intervals]; + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // are sorted in the order given by + // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.restricted_values]. + string order_by = 4; + + // The query that is used to compute facet for the given facet key. + // When provided, it will override the default behavior of facet + // computation. The query syntax is the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // detail syntax and limitations. Notice that there is no limitation on + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // when query is specified. + // + // In the response, [FacetValue.value][] will be always "1" and + // [FacetValue.count][] will be the number of results that matches the + // query. + // + // For example, you can set a customized facet for "shipToStore", + // where + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // is "customizedShipToStore", and + // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] + // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". + // Then the facet will count the products that are both in stock and ship + // to store "123". + string query = 5; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // + // By default, + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // Listing a facet key in this field allows its values to appear as facet + // results, even when they are filtered out of search results. Using this + // field does not affect what search results are returned. + // + // For example, suppose there are 100 products with the color facet "Red" + // and 200 products with the color facet "Blue". A query containing the + // filter "colorFamilies:ANY("Red")" and having "colorFamilies" as + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // would by default return only "Red" products in the search results, and + // also return "Red" with count 100 as the only color facet. Although there + // are also blue products available, "Blue" would not be shown as an + // available facet value. + // + // If "colorFamilies" is listed in "excludedFilterKeys", then the query + // returns the facet values "Red" with count 100 and "Blue" with count + // 200, because the "colorFamilies" key is now excluded from the filter. + // Because this field doesn't affect search results, the search results + // are still correctly filtered to return only "Red" products. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined by Google + // Retail Search. It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined by + // Google Retail Search. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how Google Retail Search orders "gender" and + // "rating" facets. However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // The specifications of dynamically generated facets. + message DynamicFacetSpec { + // Enum to control DynamicFacet mode + enum Mode { + // Default value. + MODE_UNSPECIFIED = 0; + + // Disable Dynamic Facet. + DISABLED = 1; + + // Automatic mode built by Google Retail Search. + ENABLED = 2; + } + + // Mode of the DynamicFacet feature. + // Defaults to + // [Mode.DISABLED][google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode.DISABLED] + // if it's unset. + Mode mode = 1; + } + + // Boost specification to boost certain items. + message BoostSpec { + // Boost applies to products which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue": + // * (id: ANY("product_1", "product_2")) AND (colorFamilies: + // ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a product matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 20. + repeated ConditionBoostSpec condition_boost_specs = 1; + + // Whether to skip boostspec validation. If this field is set to true, + // invalid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] + // will be ignored and valid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] + // will still be applied. + optional bool skip_boost_spec_validation = 2; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. This defaults to + // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.retail.v2.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by Google Retail Search. + AUTO = 3; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + + // Whether to pin unexpanded results. If this field is set to true, + // unexpanded products are always at the top of the search results, followed + // by the expanded results. + bool pin_unexpanded_results = 2; + } + + // The specification for personalization. + message PersonalizationSpec { + // The personalization mode of each search request. + enum Mode { + // Default value. Defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The specification for query spell correction. + message SpellCorrectionSpec { + // Enum describing under which mode spell correction should occur. + enum Mode { + // Unspecified spell correction mode. This defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Google Retail Search will try to find a spell suggestion if there + // is any and put in the + // [SearchResponse.corrected_query][google.cloud.retail.v2.SearchResponse.corrected_query]. + // The spell suggestion will not be used as the search query. + SUGGESTION_ONLY = 1; + + // Automatic spell correction built by Google Retail Search. Search will + // be based on the corrected query if found. + AUTO = 2; + } + + // The mode under which spell correction should take effect to + // replace the original search query. Default to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The search mode of each search request. + enum SearchMode { + // Default value. In this case both product search and faceted search will + // be performed. Both [SearchResponse.SearchResult] and + // [SearchResponse.Facet] will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only [SearchResponse.SearchResult] will be returned. + // [SearchResponse.Facet] will not be returned, even if + // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] + // or + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] + // is set. + PRODUCT_SEARCH_ONLY = 1; + + // Only faceted search will be performed. The product search will be + // disabled. + // + // When in this mode, one or both of + // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] + // and + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] + // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only + // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the search engine placement, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. + // This field is used to identify the serving configuration name and the set + // of models that will be used to make the search. + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. + // + // Use "default_branch" as the branch ID or leave this field empty, to search + // products under the default branch. + string branch = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Raw search query. + // + // If this field is empty, the request is considered a category browsing + // request and returned results are based on + // [filter][google.cloud.retail.v2.SearchRequest.filter] and + // [page_categories][google.cloud.retail.v2.SearchRequest.page_categories]. + string query = 3; + + // Required. A unique identifier for tracking visitors. For example, this + // could be implemented with an HTTP cookie, which should be able to uniquely + // identify a visitor on a single device. This unique identifier should not + // change if the visitor logs in or out of the website. + // + // This should be the same identifier as + // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; + + // User information. + UserInfo user_info = 5; + + // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If + // unspecified, defaults to a reasonable value. The maximum allowed value is + // 120. Values above 120 will be coerced to 120. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 7; + + // A page token + // [SearchResponse.next_page_token][google.cloud.retail.v2.SearchResponse.next_page_token], + // received from a previous + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] must + // match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + // error is returned. + string page_token = 8; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the [Product][google.cloud.retail.v2.Product]s + // deemed by the API as relevant) in search results. This field is only + // considered if [page_token][google.cloud.retail.v2.SearchRequest.page_token] + // is unset. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 offset = 9; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. Filter + // expression is case-sensitive. See more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string filter = 10; + + // The default filter that is applied when a user performs a search without + // checking any filters on the search page. + // + // The filter applied to every search request when quality improvement such as + // query expansion is needed. For example, if a query does not have enough + // results, an expanded query with + // [SearchRequest.canonical_filter][google.cloud.retail.v2.SearchRequest.canonical_filter] + // will be returned as a supplement of the original query. This field is + // strongly recommended to achieve high search quality. + // + // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // more details about filter syntax. + string canonical_filter = 28; + + // The order in which products are returned. Products can be ordered by + // a field in an [Product][google.cloud.retail.v2.Product] object. Leave it + // unset if ordered by relevance. OrderBy expression is case-sensitive. See + // more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#order). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string order_by = 11; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated FacetSpec facet_specs = 12; + + // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + // to enable dynamic facets. Do not set this field. + // + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; + + // Boost specification to boost certain products. See more details at this + // [user guide](https://cloud.google.com/retail/docs/boosting). + // + // Notice that if both [ServingConfig.boost_control_ids][] and + // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] + // are set, the boost conditions from both places are evaluated. If a search + // request matches multiple boost conditions, the final boost score is equal + // to the sum of the boost scores from all matched boost conditions. + BoostSpec boost_spec = 13; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + QueryExpansionSpec query_expansion_spec = 14; + + // The keys to fetch and rollup the matching + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s attributes, + // [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo] or + // [LocalInventory][google.cloud.retail.v2.LocalInventory]s attributes. The + // attributes from all the matching + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s or + // [LocalInventory][google.cloud.retail.v2.LocalInventory]s are merged and + // de-duplicated. Notice that rollup attributes will lead to extra query + // latency. Maximum number of keys is 30. + // + // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], a + // fulfillment type and a fulfillment ID must be provided in the format of + // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + // "pickupInStore" is fulfillment type and "store123" is the store ID. + // + // Supported keys are: + // + // * colorFamilies + // * price + // * originalPrice + // * discount + // * variantId + // * inventory(place_id,price) + // * inventory(place_id,original_price) + // * inventory(place_id,attributes.key), where key is any key in the + // [Product.local_inventories.attributes][google.cloud.retail.v2.LocalInventory.attributes] + // map. + // * attributes.key, where key is any key in the + // [Product.attributes][google.cloud.retail.v2.Product.attributes] map. + // * pickupInStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "pickup-in-store". + // * shipToStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "ship-to-store". + // * sameDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "same-day-delivery". + // * nextDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "next-day-delivery". + // * customFulfillment1.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-1". + // * customFulfillment2.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-2". + // * customFulfillment3.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-3". + // * customFulfillment4.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-4". + // * customFulfillment5.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-5". + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + repeated string variant_rollup_keys = 17; + + // The categories associated with a category page. Required for category + // navigation queries to achieve good search quality. The format should be + // the same as + // [UserEvent.page_categories][google.cloud.retail.v2.UserEvent.page_categories]; + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + repeated string page_categories = 23; + + // The search mode of the search request. If not specified, a single search + // request triggers both product search and faceted search. + SearchMode search_mode = 31; + + // The specification for personalization. + PersonalizationSpec personalization_spec = 32; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters and cannot be empty. Values can be empty and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 34; + + // The spell correction specification that specifies the mode under + // which spell correction will take effect. + optional SpellCorrectionSpec spell_correction_spec = 35; +} + +// Response message for +// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Product.id][google.cloud.retail.v2.Product.id] of the searched + // [Product][google.cloud.retail.v2.Product]. + string id = 1; + + // The product data snippet in the search response. Only + // [Product.name][google.cloud.retail.v2.Product.name] is guaranteed to be + // populated. + // + // [Product.variants][google.cloud.retail.v2.Product.variants] contains the + // product variants that match the search query. If there are multiple + // product variants matching the query, top 5 most relevant product variants + // are returned and ordered by relevancy. + // + // If relevancy can be deternmined, use + // [matching_variant_fields][google.cloud.retail.v2.SearchResponse.SearchResult.matching_variant_fields] + // to look up matched product variants fields. If relevancy cannot be + // determined, e.g. when searching "shoe" all products in a shoe product can + // be a match, 5 product variants are returned but order is meaningless. + Product product = 2; + + // The count of matched + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. + int32 matching_variant_count = 3; + + // If a [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] matches the search query, this + // map indicates which [Product][google.cloud.retail.v2.Product] fields are + // matched. The key is the + // [Product.name][google.cloud.retail.v2.Product.name], the value is a field + // mask of the matched [Product][google.cloud.retail.v2.Product] fields. If + // matched attributes cannot be determined, this map will be empty. + // + // For example, a key "sku1" with field mask + // "products.color_info" indicates there is a match between + // "sku1" [ColorInfo][google.cloud.retail.v2.ColorInfo] and the query. + map matching_variant_fields = 4; + + // The rollup matching + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] attributes. The key is one of + // the + // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2.SearchRequest.variant_rollup_keys]. + // The values are the merged and de-duplicated + // [Product][google.cloud.retail.v2.Product] attributes. Notice that the + // rollup values are respect filter. For example, when filtering by + // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is + // returned. + // + // For textual and numerical attributes, the rollup values is a list of + // string or double values with type + // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if + // there are two variants with colors "red" and "blue", the rollup values + // are + // + // { key: "colorFamilies" + // value { + // list_value { + // values { string_value: "red" } + // values { string_value: "blue" } + // } + // } + // } + // + // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], the rollup + // values is a double value with type + // [google.protobuf.Value][google.protobuf.Value]. For example, + // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there + // are 10 variants in this product are available in the store "store1". + map variant_rollup_values = 5; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colorFamilies". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + } + + // The key for this facet. E.g., "colorFamilies" or "price" or + // "attributes.attr1". + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Information describing query expansion including whether expansion has + // occurred. + message QueryExpansionInfo { + // Bool describing whether query expansion has occurred. + bool expanded_query = 1; + + // Number of pinned results. This field will only be set when expansion + // happens and + // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] + // is set to true. + int64 pinned_result_count = 2; + } + + // A list of matched items. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.retail.v2.SearchResponse.results] returned + // by pagination may be less than the + // [total_size][google.cloud.retail.v2.SearchResponse.total_size] that + // matches. + int32 total_size = 3; + + // Contains the spell corrected query, if found. If the spell correction type + // is AUTOMATIC, then the search results are based on corrected_query. + // Otherwise the original query will be used for search. + string corrected_query = 4; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this + // search, which enables accurate attribution of search model performance. + string attribution_token = 5; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.retail.v2.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 6; + + // Query expansion information for the returned results. + QueryExpansionInfo query_expansion_info = 7; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search is performed, and only + // [redirect_uri][google.cloud.retail.v2.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] + // are set in the response. + string redirect_uri = 10; + + // The fully qualified resource name of applied + // [controls](https://cloud.google.com/retail/docs/serving-control-rules). + repeated string applied_controls = 12; + + // The invalid + // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto new file mode 100644 index 00000000..fc315f88 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto @@ -0,0 +1,343 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// UserEvent captures all metadata information Retail API needs to know about +// how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // * `add-to-cart`: Products being added to cart. + // * `category-page-view`: Special pages such as sale or promotion pages + // viewed. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed. + // * `promotion-offered`: Promotion is offered to a user. + // * `promotion-not-offered`: Promotion is not offered to a user. + // * `purchase-complete`: User finishing a purchase. + // * `search`: Product search. + // * `shopping-cart-page-view`: User viewing a shopping cart. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A unique identifier for tracking visitors. + // + // For example, this could be implemented with an HTTP cookie, which should be + // able to uniquely identify a visitor on a single device. This unique + // identifier should not change if the visitor log in/out of the website. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded model + // quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analytics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the sesion_id: + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // visitor_id as prefix. + string session_id = 21; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.retail.v2.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups (e.g. using Retail API, using different + // recommendation models). + repeated string experiment_ids = 4; + + // Highly recommended for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be a valid + // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] + // for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. + // The value must be a valid + // [SearchResponse.attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] + // for user events that are the result of + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // This token enables us to accurately attribute page view or purchase back to + // the event and the particular predict response containing this + // clicked/purchased product. If user clicks on product K in the + // recommendation results, pass + // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] + // as a URL parameter to product K's page. When recording events on product + // K's page, log the + // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] + // to this field. + string attribution_token = 5; + + // The main product details related to the event. + // + // This field is optional except for the following event types: + // + // * `add-to-cart` + // * `detail-page-view` + // * `purchase-complete` + // + // In a `search` event, this field represents the products returned to the end + // user on the current page (the end user may have not finished browsing the + // whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [product_details][google.cloud.retail.v2.UserEvent.product_details] is + // desired. The end user may have not finished browsing the whole page yet. + repeated ProductDetail product_details = 6; + + // The main auto-completion details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionDetail completion_detail = 22; + + // Extra user event features to include in the recommendation model. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Retail API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // traffic_channel, which is how a user arrives at the site. Users can arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 7; + + // The ID or name of the associated shopping cart. This ID is used + // to associate multiple items added or present in the cart before purchase. + // + // This can only be set for `add-to-cart`, `purchase-complete`, or + // `shopping-cart-page-view` events. + string cart_id = 8; + + // A transaction represents the entire purchase transaction. + // + // Required for `purchase-complete` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + PurchaseTransaction purchase_transaction = 9; + + // The user's search query. + // + // See [SearchRequest.query][google.cloud.retail.v2.SearchRequest.query] for + // definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.retail.v2.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 10; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. + // + // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 16; + + // The order in which products are returned. + // + // See [SearchRequest.order_by][google.cloud.retail.v2.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 17; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See [SearchRequest.offset][google.cloud.retail.v2.SearchRequest.offset] for + // definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + int32 offset = 18; + + // The categories associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + // + // Required for `category-page-view` events. At least one of + // [search_query][google.cloud.retail.v2.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string page_categories = 11; + + // User information. + UserInfo user_info = 12; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 13; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string referrer_uri = 14; + + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string page_view_id = 15; +} + +// Detailed product information associated with a user event. +message ProductDetail { + // Required. [Product][google.cloud.retail.v2.Product] information. + // + // Required field(s): + // + // * [Product.id][google.cloud.retail.v2.Product.id] + // + // Optional override field(s): + // + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // + // If any supported optional fields are provided, we will treat them as a full + // override when looking up product information from the catalog. Thus, it is + // important to ensure that the overriding fields are accurate and + // complete. + // + // All other product fields are ignored and instead populated via catalog + // lookup after event ingestion. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Quantity of the product associated with the user event. + // + // For example, this field will be 2 if two products are added to the shopping + // cart for `purchase-complete` event. Required for `add-to-cart` and + // `purchase-complete` event types. + google.protobuf.Int32Value quantity = 2; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionDetail { + // Completion attribution token in + // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2.CompleteQueryResponse.attribution_token]. + string completion_attribution_token = 1; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion]. + string selected_suggestion = 2; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion] + // position, starting from 0. + int32 selected_position = 3; +} + +// A transaction represents the entire purchase transaction. +message PurchaseTransaction { + // The transaction ID with a length limit of 128 characters. + string id = 1; + + // Required. Total non-zero revenue or grand total associated with the + // transaction. This value include shipping, tax, or other adjustments to + // total revenue that you want to include as part of your revenue + // calculations. + float revenue = 2 [(google.api.field_behavior) = REQUIRED]; + + // All the taxes associated with the transaction. + float tax = 3; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = [revenue][google.cloud.retail.v2.PurchaseTransaction.revenue] - + // [tax][google.cloud.retail.v2.PurchaseTransaction.tax] - + // [cost][google.cloud.retail.v2.PurchaseTransaction.cost] + float cost = 4; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto new file mode 100644 index 00000000..4446906a --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto @@ -0,0 +1,190 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/import_config.proto"; +import "google/cloud/retail/v2/purge_config.proto"; +import "google/cloud/retail/v2/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for ingesting end user actions on the customer website. +service UserEventService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" + body: "user_event" + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Retail API JavaScript pixel and Google Tag + // Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }; + } + + // Deletes permanently all user events specified by the filter provided. + // Depending on the number of events specified by the filter, this operation + // could take hours or days to complete. To test a filter, use the list + // command first. + rpc PurgeUserEvents(PurgeUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.PurgeUserEventsResponse" + metadata_type: "google.cloud.retail.v2.PurgeMetadata" + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // Operation.response is of type ImportResponse. Note that it is + // possible for a subset of the items to be successfully inserted. + // Operation.metadata is of type ImportMetadata. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.ImportUserEventsResponse" + metadata_type: "google.cloud.retail.v2.ImportMetadata" + }; + } + + // Starts a user event rejoin operation with latest product catalog. Events + // will not be annotated with detailed product information if product is + // missing from the catalog at the time the user event is ingested, and these + // events are stored as unjoined events with a limited usage on training and + // serving. This method can be used to start a join operation on specified + // events with latest version of product catalog. It can also be used to + // correct events joined with the wrong product catalog. A rejoin operation + // can take hours or days to complete. + rpc RejoinUserEvents(RejoinUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "RejoinUserEventsResponse" + metadata_type: "RejoinUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User event to write. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent catalog name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // The URL including cgi-parameters but excluding the hash fragment with a + // length limit of 5,000 characters. This is often more useful than the + // referer URL, because many browsers only send the domain for 3rd party + // requests. + string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + int64 ets = 4; +} + +// Request message for RejoinUserEvents method. +message RejoinUserEventsRequest { + // The scope of user events to be rejoined with the latest product catalog. + // If the rejoining aims at reducing number of unjoined events, set + // UserEventRejoinScope to UNJOINED_EVENTS. + // If the rejoining aims at correcting product catalog information in joined + // events, set UserEventRejoinScope to JOINED_EVENTS. + // If all events needs to be rejoined, set UserEventRejoinScope to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. + enum UserEventRejoinScope { + // Rejoin all events with the latest product catalog, including both joined + // events and unjoined events. + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; + + // Only rejoin joined events with the latest product catalog. + JOINED_EVENTS = 1; + + // Only rejoin unjoined events with the latest product catalog. + UNJOINED_EVENTS = 2; + } + + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the user event rejoin to define the scope and range of the user + // events to be rejoined with the latest product catalog. Defaults to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + // invalid integer value. + UserEventRejoinScope user_event_rejoin_scope = 2; +} + +// Response message for RejoinUserEvents method. +message RejoinUserEventsResponse { + // Number of user events that were joined with latest product catalog. + int64 rejoined_user_events_count = 1; +} + +// Metadata for RejoinUserEvents method. +message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js new file mode 100644 index 00000000..fa840318 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js @@ -0,0 +1,58 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2_generated_CatalogService_GetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.getDefaultBranch(request); + console.log(response); + } + + callGetDefaultBranch(); + // [END retail_v2_generated_CatalogService_GetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js new file mode 100644 index 00000000..b5c79c51 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_CatalogService_ListCatalogs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The account resource name with an associated location. + * If the caller does not have permission to list + * Catalog google.cloud.retail.v2.Catalog s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Catalog google.cloud.retail.v2.Catalog s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListCatalogsResponse.next_page_token google.cloud.retail.v2.ListCatalogsResponse.next_page_token, + * received from a previous + * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callListCatalogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCatalogs(); + // [END retail_v2_generated_CatalogService_ListCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js new file mode 100644 index 00000000..f03f4c36 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2_generated_CatalogService_SetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * The final component of the resource name of a branch. + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * If there are no sufficient active products in the targeted branch and + * force google.cloud.retail.v2.SetDefaultBranchRequest.force is not set, a + * FAILED_PRECONDITION error is returned. + */ + // const branchId = 'abc123' + /** + * Some note on this request, this can be retrieved by + * CatalogService.GetDefaultBranch google.cloud.retail.v2.CatalogService.GetDefaultBranch + * before next valid default branch set occurs. + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const note = 'abc123' + /** + * If set to true, it permits switching to a branch with + * branch_id google.cloud.retail.v2.SetDefaultBranchRequest.branch_id even + * if it has no sufficient active products. + */ + // const force = true + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callSetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.setDefaultBranch(request); + console.log(response); + } + + callSetDefaultBranch(); + // [END retail_v2_generated_CatalogService_SetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js new file mode 100644 index 00000000..33d552b5 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.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(catalog) { + // [START retail_v2_generated_CatalogService_UpdateCatalog_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Catalog google.cloud.retail.v2.Catalog to update. + * If the caller does not have permission to update the + * Catalog google.cloud.retail.v2.Catalog, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the Catalog google.cloud.retail.v2.Catalog to update does not exist, + * a NOT_FOUND error is returned. + */ + // const catalog = {} + /** + * Indicates which fields in the provided + * Catalog google.cloud.retail.v2.Catalog to update. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCatalog() { + // Construct request + const request = { + catalog, + }; + + // Run request + const response = await retailClient.updateCatalog(request); + console.log(response); + } + + callUpdateCatalog(); + // [END retail_v2_generated_CatalogService_UpdateCatalog_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js b/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js new file mode 100644 index 00000000..51c1efcd --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js @@ -0,0 +1,116 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog, query) { + // [START retail_v2_generated_CompletionService_CompleteQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Catalog for which the completion is performed. + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * Required. The query used to generate suggestions. + * The maximum number of allowed characters is 255. + */ + // const query = 'abc123' + /** + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see Tags for + * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + */ + // const languageCodes = 'abc123' + /** + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * Supported formats: + * * `UNKNOWN_DEVICE_TYPE` + * * `DESKTOP` + * * `MOBILE` + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + */ + // const deviceType = 'abc123' + /** + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * CompletionService.ImportCompletionData google.cloud.retail.v2.CompletionService.ImportCompletionData. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * Current supported values: + * * user-data + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * guidelines (https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + */ + // const dataset = 'abc123' + /** + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value CompletionConfig.max_suggestions . + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + catalog, + query, + }; + + // Run request + const response = await retailClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END retail_v2_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js b/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js new file mode 100644 index 00000000..4ccdcfe6 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.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, inputConfig) { + // [START retail_v2_generated_CompletionService_ImportCompletionData_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog which the suggestions dataset belongs to. + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callImportCompletionData() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importCompletionData(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportCompletionData(); + // [END retail_v2_generated_CompletionService_ImportCompletionData_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js b/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js new file mode 100644 index 00000000..d2db6c72 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js @@ -0,0 +1,170 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, userEvent) { + // [START retail_v2_generated_PredictionService_Predict_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see Managing + * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + */ + // const placement = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * Don't set + * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id or + * UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id to the same + * fixed ID for different users. If you are trying to receive non-personalized + * recommendations (not recommended; this can negatively impact model + * performance), instead set + * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id to a + * random unique ID and leave + * UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id unset. + */ + // const userEvent = {} + /** + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + */ + // const pageSize = 1234 + /** + * The previous PredictResponse.next_page_token. + */ + // const pageToken = 'abc123' + /** + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * Examples: + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + */ + // const filter = 'abc123' + /** + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + */ + // const validateOnly = true + /** + * Additional domain specific parameters for the predictions. + * Allowed values: + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + */ + // const params = 1234 + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + + // Imports the Retail library + const {PredictionServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new PredictionServiceClient(); + + async function callPredict() { + // Construct request + const request = { + placement, + userEvent, + }; + + // Run request + const response = await retailClient.predict(request); + console.log(response); + } + + callPredict(); + // [END retail_v2_generated_PredictionService_Predict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js b/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js new file mode 100644 index 00000000..79ea0522 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2_generated_ProductService_AddFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type. Duplicate + * IDs will be automatically ignored. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * If the total number of place IDs exceeds 2000 for this + * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type after + * adding, then the update will be rejected. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * Product google.cloud.retail.v2.Product is created. If set to false, a + * NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddFulfillmentPlaces(); + // [END retail_v2_generated_ProductService_AddFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js b/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js new file mode 100644 index 00000000..f0598e36 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js @@ -0,0 +1,99 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, localInventories) { + // [START retail_v2_generated_ProductService_AddLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + */ + // const localInventories = 1234 + /** + * Indicates which inventory fields in the provided list of + * LocalInventory google.cloud.retail.v2.LocalInventory to update. The + * field is updated to the provided value. + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const addMask = {} + /** + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the local inventory will still be processed and retained for at most + * 1 day and processed once the Product google.cloud.retail.v2.Product is + * created. If set to false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddLocalInventories() { + // Construct request + const request = { + product, + localInventories, + }; + + // Run request + const [operation] = await retailClient.addLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddLocalInventories(); + // [END retail_v2_generated_ProductService_AddLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js new file mode 100644 index 00000000..e64ffbdf --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, product, productId) { + // [START retail_v2_generated_ProductService_CreateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + */ + // const parent = 'abc123' + /** + * Required. The Product google.cloud.retail.v2.Product to create. + */ + // const product = {} + /** + * Required. The ID to use for the Product google.cloud.retail.v2.Product, + * which will become the final component of the + * Product.name google.cloud.retail.v2.Product.name. + * If the caller does not have permission to create the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * This field must be unique among all + * Product google.cloud.retail.v2.Product s with the same + * parent google.cloud.retail.v2.CreateProductRequest.parent. Otherwise, an + * ALREADY_EXISTS error is returned. + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const productId = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + productId, + }; + + // Run request + const response = await retailClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END retail_v2_generated_ProductService_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js new file mode 100644 index 00000000..7838dfa1 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.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(name) { + // [START retail_v2_generated_ProductService_DeleteProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to delete the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2.Product to delete does not exist, + * a NOT_FOUND error is returned. + * The Product google.cloud.retail.v2.Product to delete can neither be a + * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION + * Product google.cloud.retail.v2.Product member nor a + * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY + * Product google.cloud.retail.v2.Product with more than one + * variants google.cloud.retail.v2.Product.Type.VARIANT. Otherwise, an + * INVALID_ARGUMENT error is returned. + * All inventory information for the named + * Product google.cloud.retail.v2.Product will be deleted. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END retail_v2_generated_ProductService_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js new file mode 100644 index 00000000..007c35ea --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_ProductService_GetProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the requested Product google.cloud.retail.v2.Product does not exist, + * a NOT_FOUND error is returned. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END retail_v2_generated_ProductService_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js b/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js new file mode 100644 index 00000000..3de37997 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js @@ -0,0 +1,99 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2_generated_ProductService_ImportProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. + */ + // const errorsConfig = {} + /** + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + */ + // const updateMask = {} + /** + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * ImportProductsRequest.parent google.cloud.retail.v2.ImportProductsRequest.parent. + * Make sure that both + * `cloud-retail-customer-data-access@system.gserviceaccount.com` and + * `service-@gcp-sa-retail.iam.gserviceaccount.com` + * have the `pubsub.topics.publish` IAM permission on the topic. + * Only supported when + * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode + * is set to `FULL`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callImportProducts() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProducts(); + // [END retail_v2_generated_ProductService_ImportProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js b/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js new file mode 100644 index 00000000..00b71a9a --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js @@ -0,0 +1,130 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_ProductService_ListProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * If the caller does not have permission to list + * Product google.cloud.retail.v2.Product s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Product google.cloud.retail.v2.Product s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT error is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListProductsResponse.next_page_token google.cloud.retail.v2.ListProductsResponse.next_page_token, + * received from a previous + * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2.ListProductsRequest.filter is unset. + * * List Product.Type.VARIANT google.cloud.retail.v2.Product.Type.VARIANT + * Product google.cloud.retail.v2.Product s sharing the same + * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY + * Product google.cloud.retail.v2.Product. For example: + * `primary_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2.Product s bundled in a + * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION + * Product google.cloud.retail.v2.Product. + * For example: + * `collection_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2.Product s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * If the specified + * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY + * Product google.cloud.retail.v2.Product or + * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION + * Product google.cloud.retail.v2.Product does not exist, a NOT_FOUND error + * is returned. + */ + // const filter = 'abc123' + /** + * The fields of Product google.cloud.retail.v2.Product to return in the + * responses. If not set or empty, the following fields are returned: + * * Product.name google.cloud.retail.v2.Product.name + * * Product.id google.cloud.retail.v2.Product.id + * * Product.title google.cloud.retail.v2.Product.title + * * Product.uri google.cloud.retail.v2.Product.uri + * * Product.images google.cloud.retail.v2.Product.images + * * Product.price_info google.cloud.retail.v2.Product.price_info + * * Product.brands google.cloud.retail.v2.Product.brands + * If "*" is provided, all fields are returned. + * Product.name google.cloud.retail.v2.Product.name is always returned no + * matter what mask is set. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const readMask = {} + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END retail_v2_generated_ProductService_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000..8824fefa --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js @@ -0,0 +1,112 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to + * Product.fulfillment_info.type google.cloud.retail.v2.FulfillmentInfo.type. + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * Product google.cloud.retail.v2.Product is created. If set to false, a + * NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveFulfillmentPlaces(); + // [END retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js new file mode 100644 index 00000000..6332ed05 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, placeIds) { + // [START retail_v2_generated_ProductService_RemoveLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + */ + // const placeIds = 'abc123' + /** + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * Product google.cloud.retail.v2.Product is created. If set to false, a + * NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveLocalInventories() { + // Construct request + const request = { + product, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveLocalInventories(); + // [END retail_v2_generated_ProductService_RemoveLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js b/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js new file mode 100644 index 00000000..4f35c54e --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js @@ -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 +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inventory) { + // [START retail_v2_generated_ProductService_SetInventory_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The inventory information to update. The allowable fields to + * update are: + * * Product.price_info google.cloud.retail.v2.Product.price_info + * * Product.availability google.cloud.retail.v2.Product.availability + * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info + * The updated inventory fields must be specified in + * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask. + * If SetInventoryRequest.inventory.name is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2.Product named in + * Product.name google.cloud.retail.v2.Product.name, regardless of whether + * or not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2.Product to update does not have + * existing inventory information, the provided inventory information will be + * inserted. + * If the Product google.cloud.retail.v2.Product to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * SetInventoryRequest.set_time google.cloud.retail.v2.SetInventoryRequest.set_time. + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in SetInventoryRequest.inventory.fulfillment_info + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types to clear in + * SetInventoryRequest.inventory.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids + * The last update time is recorded for the following inventory fields: + * * Product.price_info google.cloud.retail.v2.Product.price_info + * * Product.availability google.cloud.retail.v2.Product.availability + * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info + * If a full overwrite of inventory information while ignoring timestamps is + * needed, UpdateProduct should be invoked instead. + */ + // const inventory = {} + /** + * Indicates which inventory fields in the provided + * Product google.cloud.retail.v2.Product to update. + * At least one field must be provided. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const setMask = {} + /** + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + */ + // const setTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product with name + * Product.name google.cloud.retail.v2.Product.name is not found, the + * inventory update will still be processed and retained for at most 1 day + * until the Product google.cloud.retail.v2.Product is created. If set to + * false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callSetInventory() { + // Construct request + const request = { + inventory, + }; + + // Run request + const [operation] = await retailClient.setInventory(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInventory(); + // [END retail_v2_generated_ProductService_SetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js new file mode 100644 index 00000000..7c7a9f41 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js @@ -0,0 +1,84 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START retail_v2_generated_ProductService_UpdateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The product to update/create. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2.Product to update does not exist + * and + * allow_missing google.cloud.retail.v2.UpdateProductRequest.allow_missing + * is not set, a NOT_FOUND error is returned. + */ + // const product = {} + /** + * Indicates which fields in the provided + * Product google.cloud.retail.v2.Product to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. + */ + // const updateMask = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, a new Product google.cloud.retail.v2.Product will be created. In + * this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await retailClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END retail_v2_generated_ProductService_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/search_service.search.js b/owl-bot-staging/v2/samples/generated/v2/search_service.search.js new file mode 100644 index 00000000..26118e14 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/search_service.search.js @@ -0,0 +1,288 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, visitorId) { + // [START retail_v2_generated_SearchService_Search_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + */ + // const placement = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * filter google.cloud.retail.v2.SearchRequest.filter and + * page_categories google.cloud.retail.v2.SearchRequest.page_categories. + */ + // const query = 'abc123' + /** + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * This should be the same identifier as + * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * User information. + */ + // const userInfo = {} + /** + * Maximum number of Product google.cloud.retail.v2.Product s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * SearchResponse.next_page_token google.cloud.retail.v2.SearchResponse.next_page_token, + * received from a previous + * SearchService.Search google.cloud.retail.v2.SearchService.Search call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.retail.v2.SearchService.Search must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the Product google.cloud.retail.v2.Product s + * deemed by the API as relevant) in search results. This field is only + * considered if page_token google.cloud.retail.v2.SearchRequest.page_token + * is unset. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const filter = 'abc123' + /** + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * SearchRequest.canonical_filter google.cloud.retail.v2.SearchRequest.canonical_filter + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * See SearchRequest.filter google.cloud.retail.v2.SearchRequest.filter for + * more details about filter syntax. + */ + // const canonicalFilter = 'abc123' + /** + * The order in which products are returned. Products can be ordered by + * a field in an Product google.cloud.retail.v2.Product object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#order). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const orderBy = 'abc123' + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain products. See more details at this + * user guide (https://cloud.google.com/retail/docs/boosting). + * Notice that if both ServingConfig.boost_control_ids and + * SearchRequest.boost_spec google.cloud.retail.v2.SearchRequest.boost_spec + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + */ + // const boostSpec = {} + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). + */ + // const queryExpansionSpec = {} + /** + * The keys to fetch and rollup the matching + * variant google.cloud.retail.v2.Product.Type.VARIANT + * Product google.cloud.retail.v2.Product s attributes, + * FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo or + * LocalInventory google.cloud.retail.v2.LocalInventory s attributes. The + * attributes from all the matching + * variant google.cloud.retail.v2.Product.Type.VARIANT + * Product google.cloud.retail.v2.Product s or + * LocalInventory google.cloud.retail.v2.LocalInventory s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * For FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * Supported keys are: + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * Product.local_inventories.attributes google.cloud.retail.v2.LocalInventory.attributes + * map. + * * attributes.key, where key is any key in the + * Product.attributes google.cloud.retail.v2.Product.attributes map. + * * pickupInStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "pickup-in-store". + * * shipToStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-1". + * * customFulfillment2.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-2". + * * customFulfillment3.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-3". + * * customFulfillment4.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-4". + * * customFulfillment5.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-5". + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + */ + // const variantRollupKeys = 'abc123' + /** + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * UserEvent.page_categories google.cloud.retail.v2.UserEvent.page_categories; + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : "Sales > 2017 Black Friday Deals". + */ + // const pageCategories = 'abc123' + /** + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + */ + // const searchMode = {} + /** + * The specification for personalization. + */ + // const personalizationSpec = {} + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + */ + // const spellCorrectionSpec = {} + + // Imports the Retail library + const {SearchServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + placement, + visitorId, + }; + + // Run request + const iterable = await retailClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END retail_v2_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json new file mode 100644 index 00000000..13e48207 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json @@ -0,0 +1,1303 @@ +{ + "clientLibrary": { + "name": "nodejs-retail", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.retail.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "retail_v2_generated_CatalogService_ListCatalogs_async", + "title": "CatalogService listCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with the project.", + "canonical": true, + "file": "catalog_service.list_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ListCatalogsResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_UpdateCatalog_async", + "title": "CatalogService updateCatalog Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Catalog][google.cloud.retail.v2.Catalog]s.", + "canonical": true, + "file": "catalog_service.update_catalog.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": ".google.cloud.retail.v2.Catalog" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.Catalog", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_SetDefaultBranch_async", + "title": "CatalogService setDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", + "canonical": true, + "file": "catalog_service.set_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "branch_id", + "type": "TYPE_STRING" + }, + { + "name": "note", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_GetDefaultBranch_async", + "title": "CatalogService getDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] method under a specified parent catalog.", + "canonical": true, + "file": "catalog_service.get_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.GetDefaultBranchResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CompletionService_CompleteQuery_async", + "title": "CatalogService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 108, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "language_codes", + "type": "TYPE_STRING[]" + }, + { + "name": "device_type", + "type": "TYPE_STRING" + }, + { + "name": "dataset", + "type": "TYPE_STRING" + }, + { + "name": "max_suggestions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.retail.v2.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CompletionService_ImportCompletionData_async", + "title": "CatalogService importCompletionData Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.import_completion_data.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2.CompletionDataInputConfig" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2.CompletionServiceClient" + }, + "method": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_PredictionService_Predict_async", + "title": "CatalogService predict Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation prediction.", + "canonical": true, + "file": "prediction_service.predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 162, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2.PredictionService.Predict", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.retail.v2.PredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.retail.v2.PredictionServiceClient" + }, + "method": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2.PredictionService.Predict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.retail.v2.PredictionService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_CreateProduct_async", + "title": "CatalogService createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.retail.v2.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_GetProduct_async", + "title": "CatalogService getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2.ProductService.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2.ProductService.GetProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_ListProducts_async", + "title": "CatalogService listProducts Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Product][google.cloud.retail.v2.Product]s.", + "canonical": true, + "file": "product_service.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 122, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2.ProductService.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "read_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.ListProductsResponse", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2.ProductService.ListProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_UpdateProduct_async", + "title": "CatalogService updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.retail.v2.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_DeleteProduct_async", + "title": "CatalogService deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_ImportProducts_async", + "title": "CatalogService importProducts Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. Request processing may be synchronous. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2.Product]s to be successfully updated.", + "canonical": true, + "file": "product_service.import_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 91, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2.ProductInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2.ImportErrorsConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_SetInventory_async", + "title": "CatalogService setInventory Sample", + "origin": "API_DEFINITION", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 116, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2.ProductService.SetInventory", + "async": true, + "parameters": [ + { + "name": "inventory", + "type": ".google.cloud.retail.v2.Product" + }, + { + "name": "set_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "set_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2.ProductService.SetInventory", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_AddFulfillmentPlaces_async", + "title": "CatalogService addFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async", + "title": "CatalogService removeFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 104, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_AddLocalInventories_async", + "title": "CatalogService addLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Updates local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 91, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "local_inventories", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "add_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_RemoveLocalInventories_async", + "title": "CatalogService removeLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Remove local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_SearchService_Search_async", + "title": "CatalogService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 280, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.retail.v2.UserInfo" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "canonical_filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "dynamic_facet_spec", + "type": ".google.cloud.retail.v2.SearchRequest.DynamicFacetSpec" + }, + { + "name": "boost_spec", + "type": ".google.cloud.retail.v2.SearchRequest.BoostSpec" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.retail.v2.SearchRequest.QueryExpansionSpec" + }, + { + "name": "variant_rollup_keys", + "type": "TYPE_STRING[]" + }, + { + "name": "page_categories", + "type": "TYPE_STRING[]" + }, + { + "name": "search_mode", + "type": ".google.cloud.retail.v2.SearchRequest.SearchMode" + }, + { + "name": "personalization_spec", + "type": ".google.cloud.retail.v2.SearchRequest.PersonalizationSpec" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "spell_correction_spec", + "type": ".google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec" + } + ], + "resultType": ".google.cloud.retail.v2.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.retail.v2.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.retail.v2.SearchService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_WriteUserEvent_async", + "title": "CatalogService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2.UserEvent" + } + ], + "resultType": ".google.cloud.retail.v2.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_CollectUserEvent_async", + "title": "CatalogService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_PurgeUserEvents_async", + "title": "CatalogService purgeUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", + "canonical": true, + "file": "user_event_service.purge_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_ImportUserEvents_async", + "title": "CatalogService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2.UserEventInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2.ImportErrorsConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_RejoinUserEvents_async", + "title": "CatalogService rejoinUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", + "canonical": true, + "file": "user_event_service.rejoin_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event_rejoin_scope", + "type": ".google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js new file mode 100644 index 00000000..40992711 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2_generated_UserEventService_CollectUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + */ + // const userEvent = 'abc123' + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + */ + // const uri = 'abc123' + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + */ + // const ets = 1234 + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END retail_v2_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js new file mode 100644 index 00000000..fa18d38d --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2_generated_UserEventService_ImportUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. `projects/1234/locations/global/catalogs/default_catalog` + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorsConfig = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END retail_v2_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js new file mode 100644 index 00000000..0a008d5d --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js @@ -0,0 +1,90 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2_generated_UserEventService_PurgeUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * * `eventType`: Double quoted + * UserEvent.event_type google.cloud.retail.v2.UserEvent.event_type string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * Examples: + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * The filtering fields are assumed to have an implicit AND. + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + */ + // const force = true + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callPurgeUserEvents() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeUserEvents(); + // [END retail_v2_generated_UserEventService_PurgeUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000..925f96b6 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_UserEventService_RejoinUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + */ + // const userEventRejoinScope = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callRejoinUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await retailClient.rejoinUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRejoinUserEvents(); + // [END retail_v2_generated_UserEventService_RejoinUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js new file mode 100644 index 00000000..6df073a3 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2_generated_UserEventService_WriteUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END retail_v2_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/src/index.ts b/owl-bot-staging/v2/src/index.ts new file mode 100644 index 00000000..28988c03 --- /dev/null +++ b/owl-bot-staging/v2/src/index.ts @@ -0,0 +1,35 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 v2 from './v2'; +const CatalogServiceClient = v2.CatalogServiceClient; +type CatalogServiceClient = v2.CatalogServiceClient; +const CompletionServiceClient = v2.CompletionServiceClient; +type CompletionServiceClient = v2.CompletionServiceClient; +const PredictionServiceClient = v2.PredictionServiceClient; +type PredictionServiceClient = v2.PredictionServiceClient; +const ProductServiceClient = v2.ProductServiceClient; +type ProductServiceClient = v2.ProductServiceClient; +const SearchServiceClient = v2.SearchServiceClient; +type SearchServiceClient = v2.SearchServiceClient; +const UserEventServiceClient = v2.UserEventServiceClient; +type UserEventServiceClient = v2.UserEventServiceClient; +export {v2, CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient}; +export default {v2, CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_client.ts b/owl-bot-staging/v2/src/v2/catalog_service_client.ts new file mode 100644 index 00000000..c8d68a6b --- /dev/null +++ b/owl-bot-staging/v2/src/v2/catalog_service_client.ts @@ -0,0 +1,1058 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/catalog_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './catalog_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for managing catalog configuration. + * @class + * @memberof v2 + */ +export class CatalogServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + catalogServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CatalogServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CatalogServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listCatalogs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.CatalogService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.catalogServiceStub) { + return this.catalogServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.CatalogService. + this.catalogServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.CatalogService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.CatalogService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const catalogServiceStubMethods = + ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch']; + for (const methodName of catalogServiceStubMethods) { + const callPromise = this.catalogServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.catalogServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Updates the {@link google.cloud.retail.v2.Catalog|Catalog}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Catalog} request.catalog + * Required. The {@link google.cloud.retail.v2.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.Catalog|Catalog}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Catalog|Catalog} to update does not exist, + * a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.Catalog|Catalog} to update. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2.Catalog}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.update_catalog.js + * region_tag:retail_v2_generated_CatalogService_UpdateCatalog_async + */ + updateCatalog( + request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|undefined, {}|undefined + ]>; + updateCatalog( + request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog.name': request.catalog!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCatalog(request, options, callback); + } +/** + * Set a specified branch id as default branch. API methods such as + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search}, + * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct}, + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as + * default, setting + * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` + * as {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.branchId + * The final component of the resource name of a branch. + * + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * + * If there are no sufficient active products in the targeted branch and + * {@link google.cloud.retail.v2.SetDefaultBranchRequest.force|force} is not set, a + * FAILED_PRECONDITION error is returned. + * @param {string} request.note + * Some note on this request, this can be retrieved by + * {@link google.cloud.retail.v2.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} + * before next valid default branch set occurs. + * + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {boolean} request.force + * If set to true, it permits switching to a branch with + * {@link google.cloud.retail.v2.SetDefaultBranchRequest.branch_id|branch_id} even + * if it has no sufficient active products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.set_default_branch.js + * region_tag:retail_v2_generated_CatalogService_SetDefaultBranch_async + */ + setDefaultBranch( + request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|undefined, {}|undefined + ]>; + setDefaultBranch( + request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultBranch(request, options, callback); + } +/** + * Get which branch is currently default branch set by + * {@link google.cloud.retail.v2.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} + * method under a specified parent catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2.GetDefaultBranchResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.get_default_branch.js + * region_tag:retail_v2_generated_CatalogService_GetDefaultBranch_async + */ + getDefaultBranch( + request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|undefined, {}|undefined + ]>; + getDefaultBranch( + request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + callback: Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } + + /** + * Lists all the {@link google.cloud.retail.v2.Catalog|Catalog}s associated with + * the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2.Catalog}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogs( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.ICatalog[], + protos.google.cloud.retail.v2.IListCatalogsRequest|null, + protos.google.cloud.retail.v2.IListCatalogsResponse + ]>; + listCatalogs( + request: protos.google.cloud.retail.v2.IListCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2.ICatalog>): void; + listCatalogs( + request: protos.google.cloud.retail.v2.IListCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2.ICatalog>): void; + listCatalogs( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2.ICatalog>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2.ICatalog>): + Promise<[ + protos.google.cloud.retail.v2.ICatalog[], + protos.google.cloud.retail.v2.IListCatalogsRequest|null, + protos.google.cloud.retail.v2.IListCatalogsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listCatalogs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2.Catalog} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogsStream( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.createStream( + this.innerApiCalls.listCatalogs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCatalogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Catalog]{@link google.cloud.retail.v2.Catalog}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.list_catalogs.js + * region_tag:retail_v2_generated_CatalogService_ListCatalogs_async + */ + listCatalogsAsync( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.asyncIterate( + this.innerApiCalls['listCatalogs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.catalogServiceStub && !this._terminated) { + return this.catalogServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_client_config.json b/owl-bot-staging/v2/src/v2/catalog_service_client_config.json new file mode 100644 index 00000000..dd5a76fa --- /dev/null +++ b/owl-bot-staging/v2/src/v2/catalog_service_client_config.json @@ -0,0 +1,55 @@ +{ + "interfaces": { + "google.cloud.retail.v2.CatalogService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListCatalogs": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCatalog": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "SetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json b/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/completion_service_client.ts b/owl-bot-staging/v2/src/v2/completion_service_client.ts new file mode 100644 index 00000000..b59d288c --- /dev/null +++ b/owl-bot-staging/v2/src/v2/completion_service_client.ts @@ -0,0 +1,701 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Auto-completion service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2 + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importCompletionDataResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportCompletionDataResponse') as gax.protobuf.Type; + const importCompletionDataMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importCompletionData: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importCompletionDataResponse.decode.bind(importCompletionDataResponse), + importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.CompletionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.CompletionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.CompletionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const completionServiceStubMethods = + ['completeQuery', 'importCompletionData']; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Required. Catalog for which the completion is performed. + * + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string} request.visitorId + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {string[]} request.languageCodes + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see [Tags for + * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + * @param {string} request.deviceType + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * + * Supported formats: + * + * * `UNKNOWN_DEVICE_TYPE` + * + * * `DESKTOP` + * + * * `MOBILE` + * + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + * @param {string} request.dataset + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * {@link google.cloud.retail.v2.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * + * Current supported values: + * + * * user-data + * + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + * @param {number} request.maxSuggestions + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value {@link |CompletionConfig.max_suggestions}. + * + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2.CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/completion_service.complete_query.js + * region_tag:retail_v2_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|undefined, {}|undefined + ]>; + completeQuery( + request: protos.google.cloud.retail.v2.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request: protos.google.cloud.retail.v2.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + +/** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog which the suggestions dataset belongs to. + * + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2.CompletionDataInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/completion_service.import_completion_data.js + * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async + */ + importCompletionData( + request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importCompletionData( + request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importCompletionData(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importCompletionData()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/completion_service.import_completion_data.js + * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async + */ + async checkImportCompletionDataProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/completion_service_client_config.json b/owl-bot-staging/v2/src/v2/completion_service_client_config.json new file mode 100644 index 00000000..a6bffad0 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/completion_service_client_config.json @@ -0,0 +1,45 @@ +{ + "interfaces": { + "google.cloud.retail.v2.CompletionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ImportCompletionData": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/completion_service_proto_list.json b/owl-bot-staging/v2/src/v2/completion_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/completion_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/gapic_metadata.json b/owl-bot-staging/v2/src/v2/gapic_metadata.json new file mode 100644 index 00000000..e2fe1b36 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/gapic_metadata.json @@ -0,0 +1,345 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.retail.v2", + "libraryPackage": "@google-cloud/retail", + "services": { + "CatalogService": { + "clients": { + "grpc": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + } + } + }, + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "ProductService": { + "clients": { + "grpc": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/index.ts b/owl-bot-staging/v2/src/v2/index.ts new file mode 100644 index 00000000..79cde8aa --- /dev/null +++ b/owl-bot-staging/v2/src/v2/index.ts @@ -0,0 +1,24 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CatalogServiceClient} from './catalog_service_client'; +export {CompletionServiceClient} from './completion_service_client'; +export {PredictionServiceClient} from './prediction_service_client'; +export {ProductServiceClient} from './product_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2/src/v2/prediction_service_client.ts b/owl-bot-staging/v2/src/v2/prediction_service_client.ts new file mode 100644 index 00000000..5e1cd654 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/prediction_service_client.ts @@ -0,0 +1,613 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/prediction_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './prediction_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for making recommendation prediction. + * @class + * @memberof v2 + */ +export class PredictionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + predictionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PredictionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PredictionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.PredictionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.predictionServiceStub) { + return this.predictionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.PredictionService. + this.predictionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.PredictionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.PredictionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const predictionServiceStubMethods = + ['predict']; + for (const methodName of predictionServiceStubMethods) { + const callPromise = this.predictionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.predictionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Makes a recommendation prediction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see [Managing + * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + * @param {google.cloud.retail.v2.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * + * Don't set + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link google.cloud.retail.v2.UserInfo.user_id|UserInfo.user_id} to the same + * fixed ID for different users. If you are trying to receive non-personalized + * recommendations (not recommended; this can negatively impact model + * performance), instead set + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} to a + * random unique ID and leave + * {@link google.cloud.retail.v2.UserInfo.user_id|UserInfo.user_id} unset. + * @param {number} request.pageSize + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * @param {string} request.pageToken + * The previous PredictResponse.next_page_token. + * @param {string} request.filter + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * + * Examples: + * + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * @param {boolean} request.validateOnly + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the predictions. + * + * Allowed values: + * + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2.PredictResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/prediction_service.predict.js + * region_tag:retail_v2_generated_PredictionService_Predict_async + */ + predict( + request?: protos.google.cloud.retail.v2.IPredictRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|undefined, {}|undefined + ]>; + predict( + request: protos.google.cloud.retail.v2.IPredictRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request: protos.google.cloud.retail.v2.IPredictRequest, + callback: Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request?: protos.google.cloud.retail.v2.IPredictRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.predictionServiceStub && !this._terminated) { + return this.predictionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/prediction_service_client_config.json b/owl-bot-staging/v2/src/v2/prediction_service_client_config.json new file mode 100644 index 00000000..9ab95d31 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/prediction_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2.PredictionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json b/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/product_service_client.ts b/owl-bot-staging/v2/src/v2/product_service_client.ts new file mode 100644 index 00000000..5098955a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/product_service_client.ts @@ -0,0 +1,2223 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/product_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.retail.v2.Product|Product} information + * of the customer's website. + * @class + * @memberof v2 + */ +export class ProductServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProductServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportProductsResponse') as gax.protobuf.Type; + const importProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; + const setInventoryResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.SetInventoryResponse') as gax.protobuf.Type; + const setInventoryMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.SetInventoryMetadata') as gax.protobuf.Type; + const addFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddFulfillmentPlacesResponse') as gax.protobuf.Type; + const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; + const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; + const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; + const addLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddLocalInventoriesResponse') as gax.protobuf.Type; + const addLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddLocalInventoriesMetadata') as gax.protobuf.Type; + const removeLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveLocalInventoriesResponse') as gax.protobuf.Type; + const removeLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductsResponse.decode.bind(importProductsResponse), + importProductsMetadata.decode.bind(importProductsMetadata)), + setInventory: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInventoryResponse.decode.bind(setInventoryResponse), + setInventoryMetadata.decode.bind(setInventoryMetadata)), + addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), + addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), + removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), + removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), + addLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), + addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), + removeLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), + removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.ProductService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.productServiceStub) { + return this.productServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.ProductService. + this.productServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ProductService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.ProductService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const productServiceStubMethods = + ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; + for (const methodName of productServiceStubMethods) { + const callPromise = this.productServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.productServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + * @param {google.cloud.retail.v2.Product} request.product + * Required. The {@link google.cloud.retail.v2.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the {@link google.cloud.retail.v2.Product|Product}, + * which will become the final component of the + * {@link google.cloud.retail.v2.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * This field must be unique among all + * {@link google.cloud.retail.v2.Product|Product}s with the same + * {@link google.cloud.retail.v2.CreateProductRequest.parent|parent}. Otherwise, an + * ALREADY_EXISTS error is returned. + * + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.create_product.js + * region_tag:retail_v2_generated_ProductService_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.retail.v2.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.retail.v2.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.retail.v2.ICreateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.retail.v2.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link google.cloud.retail.v2.Product|Product} does not exist, + * a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.get_product.js + * region_tag:retail_v2_generated_ProductService_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.retail.v2.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.retail.v2.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.retail.v2.IGetProductRequest, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.retail.v2.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Updates a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Product} request.product + * Required. The product to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Product|Product} to update does not exist + * and + * {@link google.cloud.retail.v2.UpdateProductRequest.allow_missing|allow_missing} + * is not set, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.Product|Product} to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, a new {@link google.cloud.retail.v2.Product|Product} will be created. In + * this situation, `update_mask` is ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.update_product.js + * region_tag:retail_v2_generated_ProductService_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.retail.v2.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.retail.v2.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.retail.v2.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.retail.v2.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Deletes a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Product|Product} to delete does not exist, + * a NOT_FOUND error is returned. + * + * The {@link google.cloud.retail.v2.Product|Product} to delete can neither be a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} member nor a + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} with more than one + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link google.cloud.retail.v2.Product|Product} will be deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.delete_product.js + * region_tag:retail_v2_generated_ProductService_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.retail.v2.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.retail.v2.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.retail.v2.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.retail.v2.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } + +/** + * Bulk import of multiple {@link google.cloud.retail.v2.Product|Product}s. + * + * Request processing may be synchronous. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * {@link google.cloud.retail.v2.Product|Product}s to be successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + * @param {string} request.requestId + * Deprecated. This field has no effect. + * @param {google.cloud.retail.v2.ProductInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + * @param {google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * {@link google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {string} request.notificationPubsubTopic + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * {@link google.cloud.retail.v2.ImportProductsRequest.parent|ImportProductsRequest.parent}. + * Make sure that both + * `cloud-retail-customer-data-access@system.gserviceaccount.com` and + * `service-@gcp-sa-retail.iam.gserviceaccount.com` + * have the `pubsub.topics.publish` IAM permission on the topic. + * + * Only supported when + * {@link google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} + * is set to `FULL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.import_products.js + * region_tag:retail_v2_generated_ProductService_ImportProducts_async + */ + importProducts( + request?: protos.google.cloud.retail.v2.IImportProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProducts( + request: protos.google.cloud.retail.v2.IImportProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request: protos.google.cloud.retail.v2.IImportProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request?: protos.google.cloud.retail.v2.IImportProductsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.import_products.js + * region_tag:retail_v2_generated_ProductService_ImportProducts_async + */ + async checkImportProductsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates inventory information for a + * {@link google.cloud.retail.v2.Product|Product} while respecting the last update + * timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, updates are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct}, the + * specified inventory field value(s) will overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update time for the specified inventory fields will be overwritten to the + * time of the + * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} or + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2.CreateProductRequest.product|CreateProductRequest.product}, + * then any pre-existing inventory information for this product will be used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information will be preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2.ProductService.SetInventory|SetInventory}, + * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Product} request.inventory + * Required. The inventory information to update. The allowable fields to + * update are: + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.Product|Product} named in + * {@link google.cloud.retail.v2.Product.name|Product.name}, regardless of whether + * or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Product|Product} to update does not have + * existing inventory information, the provided inventory information will be + * inserted. + * + * If the {@link google.cloud.retail.v2.Product|Product} to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * {@link google.cloud.retail.v2.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. + * + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} + * + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link |SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} + * + * The last update time is recorded for the following inventory fields: + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, {@link |UpdateProduct} should be invoked instead. + * @param {google.protobuf.FieldMask} request.setMask + * Indicates which inventory fields in the provided + * {@link google.cloud.retail.v2.Product|Product} to update. + * + * At least one field must be provided. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.setTime + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} with name + * {@link google.cloud.retail.v2.Product.name|Product.name} is not found, the + * inventory update will still be processed and retained for at most 1 day + * until the {@link google.cloud.retail.v2.Product|Product} is created. If set to + * false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.set_inventory.js + * region_tag:retail_v2_generated_ProductService_SetInventory_async + */ + setInventory( + request?: protos.google.cloud.retail.v2.ISetInventoryRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInventory( + request: protos.google.cloud.retail.v2.ISetInventoryRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request: protos.google.cloud.retail.v2.ISetInventoryRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request?: protos.google.cloud.retail.v2.ISetInventoryRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'inventory.name': request.inventory!.name || '', + }); + this.initialize(); + return this.innerApiCalls.setInventory(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInventory()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.set_inventory.js + * region_tag:retail_v2_generated_ProductService_SetInventory_async + */ + async checkSetInventoryProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally adds place IDs to + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}. Duplicate + * IDs will be automatically ignored. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * If the total number of place IDs exceeds 2000 for this + * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type} after + * adding, then the update will be rejected. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async + */ + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async + */ + async checkAddFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally removes place IDs from a + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to + * {@link google.cloud.retail.v2.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async + */ + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async + */ + async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates local inventory information for a + * {@link google.cloud.retail.v2.Product|Product} at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} has no + * effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {number[]} request.localInventories + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + * @param {google.protobuf.FieldMask} request.addMask + * Indicates which inventory fields in the provided list of + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory} to update. The + * field is updated to the provided value. + * + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the local inventory will still be processed and retained for at most + * 1 day and processed once the {@link google.cloud.retail.v2.Product|Product} is + * created. If set to false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_local_inventories.js + * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async + */ + addLocalInventories( + request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addLocalInventories( + request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_local_inventories.js + * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async + */ + async checkAddLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Remove local inventory information for a + * {@link google.cloud.retail.v2.Product|Product} at a list of places at a removal + * timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} has no + * effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {string[]} request.placeIds + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_local_inventories.js + * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async + */ + removeLocalInventories( + request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeLocalInventories( + request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_local_inventories.js + * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async + */ + async checkRemoveLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.retail.v2.Product|Product}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2.Product|Product}s sharing the same + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} or + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error + * is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2.Product.name|Product.name} + * * {@link google.cloud.retail.v2.Product.id|Product.id} + * * {@link google.cloud.retail.v2.Product.title|Product.title} + * * {@link google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2.Product.images|Product.images} + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no + * matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.retail.v2.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IProduct[], + protos.google.cloud.retail.v2.IListProductsRequest|null, + protos.google.cloud.retail.v2.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.retail.v2.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2.IProduct>): void; + listProducts( + request: protos.google.cloud.retail.v2.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2.IProduct>): void; + listProducts( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2.IProduct>): + Promise<[ + protos.google.cloud.retail.v2.IProduct[], + protos.google.cloud.retail.v2.IListProductsRequest|null, + protos.google.cloud.retail.v2.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2.Product|Product}s sharing the same + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} or + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error + * is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2.Product.name|Product.name} + * * {@link google.cloud.retail.v2.Product.id|Product.id} + * * {@link google.cloud.retail.v2.Product.title|Product.title} + * * {@link google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2.Product.images|Product.images} + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no + * matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2.Product|Product}s sharing the same + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} or + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error + * is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2.Product.name|Product.name} + * * {@link google.cloud.retail.v2.Product.id|Product.id} + * * {@link google.cloud.retail.v2.Product.title|Product.title} + * * {@link google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2.Product.images|Product.images} + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no + * matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.retail.v2.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/product_service.list_products.js + * region_tag:retail_v2_generated_ProductService_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.productServiceStub && !this._terminated) { + return this.productServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/product_service_client_config.json b/owl-bot-staging/v2/src/v2/product_service_client_config.json new file mode 100644 index 00000000..32245ac6 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/product_service_client_config.json @@ -0,0 +1,99 @@ +{ + "interfaces": { + "google.cloud.retail.v2.ProductService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "GetProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ListProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "UpdateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "DeleteProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportProducts": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "SetInventory": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/product_service_proto_list.json b/owl-bot-staging/v2/src/v2/product_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/product_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/search_service_client.ts b/owl-bot-staging/v2/src/v2/search_service_client.ts new file mode 100644 index 00000000..c2886df0 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/search_service_client.ts @@ -0,0 +1,1324 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2 + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + search: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.SearchService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.SearchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.SearchService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const searchServiceStubMethods = + ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for + * more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both {@link |ServingConfig.boost_control_ids} and + * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s attributes, + * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.retail.v2.ISearchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2.ISearchRequest|null, + protos.google.cloud.retail.v2.ISearchResponse + ]>; + search( + request: protos.google.cloud.retail.v2.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): void; + search( + request: protos.google.cloud.retail.v2.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): void; + search( + request?: protos.google.cloud.retail.v2.ISearchRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): + Promise<[ + protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2.ISearchRequest|null, + protos.google.cloud.retail.v2.ISearchResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for + * more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both {@link |ServingConfig.boost_control_ids} and + * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s attributes, + * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.retail.v2.ISearchRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `search`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for + * more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both {@link |ServingConfig.boost_control_ids} and + * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s attributes, + * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/search_service.search.js + * region_tag:retail_v2_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.retail.v2.ISearchRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/search_service_client_config.json b/owl-bot-staging/v2/src/v2/search_service_client_config.json new file mode 100644 index 00000000..5132c12d --- /dev/null +++ b/owl-bot-staging/v2/src/v2/search_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2.SearchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/search_service_proto_list.json b/owl-bot-staging/v2/src/v2/search_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/search_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/src/v2/user_event_service_client.ts b/owl-bot-staging/v2/src/v2/user_event_service_client.ts new file mode 100644 index 00000000..18b3688e --- /dev/null +++ b/owl-bot-staging/v2/src/v2/user_event_service_client.ts @@ -0,0 +1,966 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on the customer website. + * @class + * @memberof v2 + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const purgeUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.PurgeUserEventsResponse') as gax.protobuf.Type; + const purgeUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.PurgeMetadata') as gax.protobuf.Type; + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportUserEventsResponse') as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; + const rejoinUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RejoinUserEventsResponse') as gax.protobuf.Type; + const rejoinUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RejoinUserEventsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), + purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata)), + rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), + rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.UserEventService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.UserEventService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.UserEventService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const userEventServiceStubMethods = + ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2.UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.write_user_event.js + * region_tag:retail_v2_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|undefined, {}|undefined + ]>; + writeUserEvent( + request: protos.google.cloud.retail.v2.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request: protos.google.cloud.retail.v2.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } +/** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.collect_user_event.js + * region_tag:retail_v2_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|undefined, {}|undefined + ]>; + collectUserEvent( + request: protos.google.cloud.retail.v2.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request: protos.google.cloud.retail.v2.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + +/** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + * @param {string} request.filter + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * + * * `eventType`: Double quoted + * {@link google.cloud.retail.v2.UserEvent.event_type|UserEvent.event_type} string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * + * Examples: + * + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * + * The filtering fields are assumed to have an implicit AND. + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.purge_user_events.js + * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async + */ + purgeUserEvents( + request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeUserEvents( + request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.purgeUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.purge_user_events.js + * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async + */ + async checkPurgeUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. `projects/1234/locations/global/catalogs/default_catalog` + * @param {google.cloud.retail.v2.UserEventInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.import_user_events.js + * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importUserEvents( + request: protos.google.cloud.retail.v2.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request: protos.google.cloud.retail.v2.IImportUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.import_user_events.js + * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a user event rejoin operation with latest product catalog. Events + * will not be annotated with detailed product information if product is + * missing from the catalog at the time the user event is ingested, and these + * events are stored as unjoined events with a limited usage on training and + * serving. This method can be used to start a join operation on specified + * events with latest version of product catalog. It can also be used to + * correct events joined with the wrong product catalog. A rejoin operation + * can take hours or days to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js + * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async + */ + rejoinUserEvents( + request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rejoinUserEvents( + request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.rejoinUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rejoinUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js + * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async + */ + async checkRejoinUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/user_event_service_client_config.json b/owl-bot-staging/v2/src/v2/user_event_service_client_config.json new file mode 100644 index 00000000..a3938b37 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/user_event_service_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.retail.v2.UserEventService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "CollectUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "PurgeUserEvents": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportUserEvents": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "RejoinUserEvents": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json b/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json new file mode 100644 index 00000000..dd7dfb7a --- /dev/null +++ b/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..ffbb2218 --- /dev/null +++ b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const retail = require('@google-cloud/retail'); + +function main() { + const catalogServiceClient = new retail.CatalogServiceClient(); + const completionServiceClient = new retail.CompletionServiceClient(); + const predictionServiceClient = new retail.PredictionServiceClient(); + const productServiceClient = new retail.ProductServiceClient(); + const searchServiceClient = new retail.SearchServiceClient(); + const userEventServiceClient = new retail.UserEventServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..285edd82 --- /dev/null +++ b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts @@ -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. ** + +import {CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient} from '@google-cloud/retail'; + +// check that the client class type name can be used +function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { + client.close(); +} +function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { + client.close(); +} +function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { + client.close(); +} +function doStuffWithProductServiceClient(client: ProductServiceClient) { + client.close(); +} +function doStuffWithSearchServiceClient(client: SearchServiceClient) { + client.close(); +} +function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const catalogServiceClient = new CatalogServiceClient(); + doStuffWithCatalogServiceClient(catalogServiceClient); + // check that the client instance can be created + const completionServiceClient = new CompletionServiceClient(); + doStuffWithCompletionServiceClient(completionServiceClient); + // check that the client instance can be created + const predictionServiceClient = new PredictionServiceClient(); + doStuffWithPredictionServiceClient(predictionServiceClient); + // check that the client instance can be created + const productServiceClient = new ProductServiceClient(); + doStuffWithProductServiceClient(productServiceClient); + // check that the client instance can be created + const searchServiceClient = new SearchServiceClient(); + doStuffWithSearchServiceClient(searchServiceClient); + // check that the client instance can be created + const userEventServiceClient = new UserEventServiceClient(); + doStuffWithUserEventServiceClient(userEventServiceClient); +} + +main(); diff --git a/owl-bot-staging/v2/system-test/install.ts b/owl-bot-staging/v2/system-test/install.ts new file mode 100644 index 00000000..8ec45222 --- /dev/null +++ b/owl-bot-staging/v2/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/v2/test/gapic_catalog_service_v2.ts b/owl-bot-staging/v2/test/gapic_catalog_service_v2.ts new file mode 100644 index 00000000..8a1bf5ac --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_catalog_service_v2.ts @@ -0,0 +1,903 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as catalogserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2.CatalogServiceClient', () => { + it('has servicePath', () => { + const servicePath = catalogserviceModule.v2.CatalogServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = catalogserviceModule.v2.CatalogServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = catalogserviceModule.v2.CatalogServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new catalogserviceModule.v2.CatalogServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + await client.initialize(); + assert(client.catalogServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.catalogServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('updateCatalog', () => { + it('invokes updateCatalog without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); + const [response] = await client.updateCatalog(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCatalog( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.ICatalog|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCatalog with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCatalog(request), expectedError); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCatalog(request), expectedError); + }); + }); + + describe('setDefaultBranch', () => { + it('invokes setDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultBranch( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultBranch(request), expectedError); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultBranch(request), expectedError); + }); + }); + + describe('getDefaultBranch', () => { + it('invokes getDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.getDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDefaultBranch( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IGetDefaultBranchResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDefaultBranch(request), expectedError); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDefaultBranch(request), expectedError); + }); + }); + + describe('listCatalogs', () => { + it('invokes listCatalogs without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.listCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogs without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCatalogs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.ICatalog[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCatalogs with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCatalogs(request), expectedError); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogsStream without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCatalogsStream with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.ICatalog[] = []; + const iterable = client.listCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_completion_service_v2.ts b/owl-bot-staging/v2/test/gapic_completion_service_v2.ts new file mode 100644 index 00000000..c15e5c3f --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_completion_service_v2.ts @@ -0,0 +1,503 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as completionserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2.CompletionServiceClient', () => { + it('has servicePath', () => { + const servicePath = completionserviceModule.v2.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = completionserviceModule.v2.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v2.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new completionserviceModule.v2.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.ICompleteQueryResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('importCompletionData', () => { + it('invokes importCompletionData without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); + const [operation] = await client.importCompletionData(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCompletionData( + request, + (err?: Error|null, + result?: LROperation|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.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importCompletionData with call error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importCompletionData(request), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData with LRO error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportCompletionDataProgress without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportCompletionDataProgress with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts b/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts new file mode 100644 index 00000000..efa20c2b --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts @@ -0,0 +1,343 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as predictionserviceModule from '../src'; + +import {protobuf} 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('v2.PredictionServiceClient', () => { + it('has servicePath', () => { + const servicePath = predictionserviceModule.v2.PredictionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = predictionserviceModule.v2.PredictionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = predictionserviceModule.v2.PredictionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new predictionserviceModule.v2.PredictionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + await client.initialize(); + assert(client.predictionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.predictionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('predict', () => { + it('invokes predict without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCall(expectedResponse); + const [response] = await client.predict(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.predict( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IPredictResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes predict with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict with closed client', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); + request.placement = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_product_service_v2.ts b/owl-bot-staging/v2/test/gapic_product_service_v2.ts new file mode 100644 index 00000000..aafd946a --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_product_service_v2.ts @@ -0,0 +1,1846 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as productserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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('v2.ProductServiceClient', () => { + it('has servicePath', () => { + const servicePath = productserviceModule.v2.ProductServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productserviceModule.v2.ProductServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productserviceModule.v2.ProductServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productserviceModule.v2.ProductServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productserviceModule.v2.ProductServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + await client.initialize(); + assert(client.productServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('importProducts', () => { + it('invokes importProducts without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProducts( + request, + (err?: Error|null, + result?: LROperation|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.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProducts with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProducts(request), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductsProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductsProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInventory', () => { + it('invokes setInventory without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInventory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInventory( + request, + (err?: Error|null, + result?: LROperation|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.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setInventory with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInventory(request), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkSetInventoryProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInventoryProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInventoryProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addFulfillmentPlaces', () => { + it('invokes addFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeFulfillmentPlaces', () => { + it('invokes removeFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addLocalInventories', () => { + it('invokes addLocalInventories without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.addLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addLocalInventories with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addLocalInventories(request), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeLocalInventories', () => { + it('invokes removeLocalInventories without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeLocalInventories with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeLocalInventories(request), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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.retail.v2.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.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.retail.v2.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_search_service_v2.ts b/owl-bot-staging/v2/test/gapic_search_service_v2.ts new file mode 100644 index 00000000..44857ae4 --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_search_service_v2.ts @@ -0,0 +1,570 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2.SearchServiceClient', () => { + it('has servicePath', () => { + const servicePath = searchserviceModule.v2.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = searchserviceModule.v2.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v2.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v2.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts b/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts new file mode 100644 index 00000000..2cb56664 --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts @@ -0,0 +1,888 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as usereventserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2.UserEventServiceClient', () => { + it('has servicePath', () => { + const servicePath = usereventserviceModule.v2.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = usereventserviceModule.v2.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v2.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v2.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IUserEvent|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('purgeUserEvents', () => { + it('invokes purgeUserEvents without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeUserEvents with call error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeUserEvents(request), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rejoinUserEvents', () => { + it('invokes rejoinUserEvents without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.rejoinUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejoinUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes rejoinUserEvents with call error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRejoinUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRejoinUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/tsconfig.json b/owl-bot-staging/v2/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v2/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/v2/webpack.config.js b/owl-bot-staging/v2/webpack.config.js new file mode 100644 index 00000000..f2c58f25 --- /dev/null +++ b/owl-bot-staging/v2/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CatalogService', + filename: './catalog-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v2alpha/.eslintignore b/owl-bot-staging/v2alpha/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v2alpha/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v2alpha/.eslintrc.json b/owl-bot-staging/v2alpha/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v2alpha/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v2alpha/.gitignore b/owl-bot-staging/v2alpha/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v2alpha/.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/v2alpha/.jsdoc.js b/owl-bot-staging/v2alpha/.jsdoc.js new file mode 100644 index 00000000..19729810 --- /dev/null +++ b/owl-bot-staging/v2alpha/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v2alpha/.mocharc.js b/owl-bot-staging/v2alpha/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v2alpha/.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/v2alpha/.prettierrc.js b/owl-bot-staging/v2alpha/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v2alpha/.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/v2alpha/README.md b/owl-bot-staging/v2alpha/README.md new file mode 100644 index 00000000..822c4573 --- /dev/null +++ b/owl-bot-staging/v2alpha/README.md @@ -0,0 +1 @@ +Retail: Nodejs Client diff --git a/owl-bot-staging/v2alpha/linkinator.config.json b/owl-bot-staging/v2alpha/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v2alpha/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/v2alpha/package.json b/owl-bot-staging/v2alpha/package.json new file mode 100644 index 00000000..94071ee3 --- /dev/null +++ b/owl-bot-staging/v2alpha/package.json @@ -0,0 +1,71 @@ +{ + "name": "@google-cloud/retail", + "version": "0.1.0", + "description": "Retail client for Node.js", + "repository": "googleapis/nodejs-retail", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google retail", + "retail", + "catalog service", + "completion service", + "control service", + "prediction service", + "product service", + "search service", + "serving config service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto new file mode 100644 index 00000000..9b3d8cb0 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto @@ -0,0 +1,397 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configures what level the product should be uploaded with regards to +// how users will be send events and how predictions will be made. +message ProductLevelConfig { + // The type of [Product][google.cloud.retail.v2alpha.Product]s allowed to be + // ingested into the catalog. Acceptable values are: + // + // * `primary` (default): You can ingest + // [Product][google.cloud.retail.v2alpha.Product]s of all types. When + // ingesting a [Product][google.cloud.retail.v2alpha.Product], its type will + // default to + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // if unset. + // * `variant`: You can only ingest + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s. + // This means + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] + // cannot be empty. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `variant` and + // [merchant_center_product_id_field][google.cloud.retail.v2alpha.ProductLevelConfig.merchant_center_product_id_field] + // is `itemGroupId`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string ingestion_product_type = 1; + + // Which field of [Merchant Center + // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be + // imported as [Product.id][google.cloud.retail.v2alpha.Product.id]. + // Acceptable values are: + // + // * `offerId` (default): Import `offerId` as the product ID. + // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail + // API will choose one item from the ones with the same `itemGroupId`, and + // use it to represent the item group. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `itemGroupId` and + // [ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] + // is `variant`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string merchant_center_product_id_field = 2; +} + +// Catalog level attribute config for an attribute. For example, if customers +// want to enable/disable facet for a specific attribute. +message CatalogAttribute { + // The type of an attribute. + enum AttributeType { + // The type of the attribute is unknown. + // + // Used when type cannot be derived from attribute that is not + // [in_use][google.cloud.retail.v2alpha.CatalogAttribute.in_use]. + UNKNOWN = 0; + + // Textual attribute. + TEXTUAL = 1; + + // Numerical attribute. + NUMERICAL = 2; + } + + // The status of the indexable option of a catalog attribute. + enum IndexableOption { + // Value used when unset. Defaults to + // [INDEXABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. + INDEXABLE_OPTION_UNSPECIFIED = 0; + + // Indexable option enabled for an attribute. + INDEXABLE_ENABLED = 1; + + // Indexable option disabled for an attribute. + INDEXABLE_DISABLED = 2; + } + + // The status of the dynamic facetable option of a catalog attribute. + enum DynamicFacetableOption { + // Value used when unset. Defaults to + // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; + + // Dynamic facetable option enabled for an attribute. + DYNAMIC_FACETABLE_ENABLED = 1; + + // Dynamic facetable option disabled for an attribute. + DYNAMIC_FACETABLE_DISABLED = 2; + } + + // The status of the searchable option of a catalog attribute. + enum SearchableOption { + // Value used when unset. Defaults to + // [SEARCHABLE_DISABLED][google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Indicates whether this attribute has been used by any + // products. `True` if at least one + // [Product][google.cloud.retail.v2alpha.Product] is using this attribute in + // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. + // Otherwise, this field is `False`. + // + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] can be + // pre-loaded by using [AddCatalogAttribute][], [ImportCatalogAttributes][], + // or [UpdateAttributesConfig][] APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s. + // + // Only [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that + // are not in use by products can be deleted. + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that are + // in use by products cannot be deleted; however, their configuration + // properties will reset to default values upon removal request. + // + // After catalog changes, it takes about 10 minutes for this field to update. + bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The type of this attribute. This is derived from the attribute + // in [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. + AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values + // are indexed so that it can be filtered, faceted, or boosted in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + IndexableOption indexable_option = 5; + + // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic + // facet. Could only be DYNAMIC_FACETABLE_DISABLED if + // [CatalogAttribute.indexable_option][google.cloud.retail.v2alpha.CatalogAttribute.indexable_option] + // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. + DynamicFacetableOption dynamic_facetable_option = 6; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values + // are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values + // will not be searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], + // as there are no text values associated to numerical attributes. + SearchableOption searchable_option = 7; +} + +// Catalog level attribute config. +message AttributesConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/AttributesConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }; + + // Required. Immutable. The fully qualified resource name of the attribute + // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Enable attribute(s) config at catalog level. + // For example, indexable, dynamic_facetable, or searchable for each + // attribute. + // + // The key is catalog attribute's name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // + // The maximum number of catalog attributes allowed in a request is 1000. + map catalog_attributes = 2; + + // Output only. The + // [AttributeConfigLevel][google.cloud.retail.v2alpha.AttributeConfigLevel] + // used for this catalog. + AttributeConfigLevel attribute_config_level = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Catalog level autocomplete config for customers to customize autocomplete +// feature's settings. +message CompletionConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/CompletionConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }; + + // Required. Immutable. Fully qualified name + // `projects/*/locations/*/catalogs/*/completionConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Specifies the matching order for autocomplete suggestions, e.g., a query + // consisting of 'sh' with 'out-of-order' specified would suggest "women's + // shoes", whereas a query of 'red s' with 'exact-prefix' specified would + // suggest "red shoes". Currently supported values: + // + // * 'out-of-order' + // * 'exact-prefix' + // + // Default value: 'exact-prefix'. + string matching_order = 2; + + // The maximum number of autocomplete suggestions returned per term. The + // maximum allowed max suggestions is 20. Default value is 20. If left unset + // or set to 0, then will fallback to default value. + int32 max_suggestions = 3; + + // The minimum number of characters needed to be typed in order to get + // suggestions. Default value is 2. If left unset or set to 0, then will + // fallback to default value. + int32 min_prefix_length = 4; + + // If set to true, the auto learning function is enabled. Auto learning uses + // user data to generate suggestions using ML techniques. Default value is + // false. Only after enabling auto learning can users use `cloud-retail` + // data in + // [CompleteQueryRequest][google.cloud.retail.v2alpha.CompleteQueryRequest]. + bool auto_learning = 11; + + // Output only. The input config for the import of the source data that + // contains the autocomplete phrases uploaded by the customer. + CompletionDataInputConfig suggestions_input_config = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest suggestion terms + // list import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_suggestions_import_operation = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The input config for the import of the source data that + // contains the / autocomplete denylist phrases uploaded by the customer. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. LRO corresponding to the latest denylist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_denylist_import_operation = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The input config for the import of the source data that + // contains the autocomplete allowlist phrases uploaded by the customer. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. LRO corresponding to the latest allowlist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_allowlist_import_operation = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Represents a link between a Merchant Center account and a branch. +// Once a link is established, products from the linked merchant center account +// will be streamed to the linked branch. +message MerchantCenterLink { + // Required. The linked [Merchant center account + // id](https://developers.google.com/shopping-content/guides/accountstatuses). + // The account must be a standalone account or a sub-account of a MCA. + int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch id (e.g. 0/1/2) within this catalog that products from + // merchant_center_account_id are streamed to. When updating this field, an + // empty value will use the currently configured default branch. However, + // changing the default branch later on won't change the linked branch here. + // + // A single branch id can only have one linked merchant center account id. + string branch_id = 2; + + // String representing the destination to import for, all if left empty. + // List of possible values can be found here. + // [https://support.google.com/merchants/answer/7501026] + // List of allowed string values: + // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory + // _ads", "Free_listings", "Free_local_listings" + // NOTE: The string values are case sensitive. + repeated string destinations = 3; + + // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 + // code. List of values can be found + // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) + // under the `region` tag. If left blank no region filtering will be + // performed. + // + // Example value: `US`. + string region_code = 4; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // ISO 639-1. + // + // This specifies the language of offers in Merchant Center that will be + // accepted. If empty no language filtering will be performed. + // + // Example value: `en`. + string language_code = 5; +} + +// Configures Merchant Center linking. +// Links contained in the config will be used to sync data from a Merchant +// Center account to a Cloud Retail branch. +message MerchantCenterLinkingConfig { + // Links between Merchant Center accounts and branches. + repeated MerchantCenterLink links = 1; +} + +// The catalog configuration. +message Catalog { + option (google.api.resource) = { + type: "retail.googleapis.com/Catalog" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" + }; + + // Required. Immutable. The fully qualified resource name of the catalog. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The catalog display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. The product level configuration. + ProductLevelConfig product_level_config = 4 + [(google.api.field_behavior) = REQUIRED]; + + // The Merchant Center linking configuration. + // Once a link is added, the data stream from Merchant Center to Cloud Retail + // will be enabled automatically. The requester must have access to the + // merchant center account in order to make changes to this field. + MerchantCenterLinkingConfig merchant_center_linking_config = 6; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto new file mode 100644 index 00000000..6ecab725 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto @@ -0,0 +1,478 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/catalog.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for managing catalog configuration. +service CatalogService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated + // with the project. + rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*}/catalogs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s. + rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { + option (google.api.http) = { + patch: "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}" + body: "catalog" + }; + option (google.api.method_signature) = "catalog,update_mask"; + } + + // Set a specified branch id as default branch. API methods such as + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] + // will treat requests using "default_branch" to the actual branch id set as + // default. + // + // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + // default, setting + // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + // to setting + // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/1`. + // + // Using multiple branches can be useful when developers would like + // to have a staging branch to test and verify for future usage. When it + // becomes ready, developers switch on the staging branch using this API while + // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + // as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] + // to route the traffic to this staging branch. + // + // CAUTION: If you have live predict/search traffic, switching the default + // branch could potentially cause outages if the ID space of the new branch is + // very different from the old one. + // + // More specifically: + // + // * PredictionService will only return product IDs from branch {newBranch}. + // * SearchService will only return product IDs from branch {newBranch} + // (if branch is not explicitly set). + // * UserEventService will only join events with products from branch + // {newBranch}. + rpc SetDefaultBranch(SetDefaultBranchRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" + body: "*" + }; + option (google.api.method_signature) = "catalog"; + } + + // Get which branch is currently default branch set by + // [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] + // method under a specified parent catalog. + rpc GetDefaultBranch(GetDefaultBranchRequest) + returns (GetDefaultBranchResponse) { + option (google.api.http) = { + get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + }; + option (google.api.method_signature) = "catalog"; + } + + // Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]. + rpc GetCompletionConfig(GetCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/completionConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s. + rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + patch: "/v2alpha/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" + body: "completion_config" + }; + option (google.api.method_signature) = "completion_config,update_mask"; + } + + // Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + rpc GetAttributesConfig(GetAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + // + // The catalog attributes in the request will be updated in the catalog, or + // inserted if they do not exist. Existing catalog attributes not included in + // the request will remain unchanged. Attributes that are assigned to + // products, but do not exist at the catalog level, are always included in the + // response. The product attribute is assigned default values for missing + // catalog attribute fields, e.g., searchable and dynamic facetable options. + rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + patch: "/v2alpha/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" + body: "attributes_config" + }; + option (google.api.method_signature) = "attributes_config,update_mask"; + } + + // Adds the specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to + // add already exists, an ALREADY_EXISTS error is returned. + rpc AddCatalogAttribute(AddCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" + body: "*" + }; + } + + // Removes the specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to + // remove does not exist, a NOT_FOUND error is returned. + rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" + body: "*" + }; + } + + // Replaces the specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by + // updating the catalog attribute with the same + // [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. + // + // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to + // replace does not exist, a NOT_FOUND error is returned. + rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" + body: "*" + }; + } +} + +// Request for +// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] +// method. +message ListCatalogsRequest { + // Required. The account resource name with an associated location. + // + // If the caller does not have permission to list + // [Catalog][google.cloud.retail.v2alpha.Catalog]s under this location, + // regardless of whether or not this location exists, a PERMISSION_DENIED + // error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of [Catalog][google.cloud.retail.v2alpha.Catalog]s to + // return. If unspecified, defaults to 50. The maximum allowed value is 1000. + // Values above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 2; + + // A page token + // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token], + // received from a previous + // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; +} + +// Response for +// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] +// method. +message ListCatalogsResponse { + // All the customer's [Catalog][google.cloud.retail.v2alpha.Catalog]s. + repeated Catalog catalogs = 1; + + // A token that can be sent as + // [ListCatalogsRequest.page_token][google.cloud.retail.v2alpha.ListCatalogsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request for +// [CatalogService.UpdateCatalog][google.cloud.retail.v2alpha.CatalogService.UpdateCatalog] +// method. +message UpdateCatalogRequest { + // Required. The [Catalog][google.cloud.retail.v2alpha.Catalog] to update. + // + // If the caller does not have permission to update the + // [Catalog][google.cloud.retail.v2alpha.Catalog], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Catalog][google.cloud.retail.v2alpha.Catalog] to update does not + // exist, a NOT_FOUND error is returned. + Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Catalog][google.cloud.retail.v2alpha.Catalog] to update. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message to set a specified branch as new default_branch. +message SetDefaultBranchRequest { + // Full resource name of the catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // The final component of the resource name of a branch. + // + // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // If there are no sufficient active products in the targeted branch and + // [force][google.cloud.retail.v2alpha.SetDefaultBranchRequest.force] is not + // set, a FAILED_PRECONDITION error is returned. + string branch_id = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Some note on this request, this can be retrieved by + // [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch] + // before next valid default branch set occurs. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string note = 3; + + // If set to true, it permits switching to a branch with + // [branch_id][google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id] + // even if it has no sufficient active products. + bool force = 4; +} + +// Request message to show which branch is currently the default branch. +message GetDefaultBranchRequest { + // The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response message of +// [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch]. +message GetDefaultBranchResponse { + // Full resource name of the branch id currently set as default branch. + string branch = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // The time when this branch is set to default. + google.protobuf.Timestamp set_time = 2; + + // This corresponds to + // [SetDefaultBranchRequest.note][google.cloud.retail.v2alpha.SetDefaultBranchRequest.note] + // field, when this branch was set as default. + string note = 3; +} + +// Request for +// [CatalogService.GetCompletionConfig][google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig] +// method. +message GetCompletionConfigRequest { + // Required. Full CompletionConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/CompletionConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig] +// method. +message UpdateCompletionConfigRequest { + // Required. The + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. + // + // If the caller does not have permission to update the + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig], then a + // PERMISSION_DENIED error is returned. + // + // If the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to + // update does not exist, a NOT_FOUND error is returned. + CompletionConfig completion_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. + // The following are the only supported fields: + // + // * [CompletionConfig.matching_order][google.cloud.retail.v2alpha.CompletionConfig.matching_order] + // * [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions] + // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length] + // * [CompletionConfig.auto_learning][google.cloud.retail.v2alpha.CompletionConfig.auto_learning] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.GetAttributesConfig][google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig] +// method. +message GetAttributesConfigRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig] +// method. +message UpdateAttributesConfigRequest { + // Required. The + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. + AttributesConfig attributes_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. + // The following is the only supported field: + // + // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute] +// method. +message AddCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute] +// method. +message RemoveCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The attribute name key of the + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove. + string key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute] +// method. +message ReplaceCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The updated + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to update. + // The following are NOT supported: + // + // * [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 3; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto new file mode 100644 index 00000000..ae33d3f6 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto @@ -0,0 +1,761 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// At which level we offer configuration for attributes. +enum AttributeConfigLevel { + // Value used when unset. Defaults to + // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2alpha.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; + + // At this level, we honor the attribute configurations set in + // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; + + // At this level, we honor the attribute configurations set in + // [CatalogConfig.attribute_configs][google.cloud.retail.v2alpha.CatalogConfig.attribute_configs]. + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; +} + +// The type of solution. +enum SolutionType { + // Default value. + SOLUTION_TYPE_UNSPECIFIED = 0; + + // Used for Recommendations AI. + SOLUTION_TYPE_RECOMMENDATION = 1; + + // Used for Retail Search. + SOLUTION_TYPE_SEARCH = 2; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. Defaults to + // [SEARCH][]. + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; + + // Search use case. Expects the traffic has a non-empty + // [query][google.cloud.retail.v2alpha.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_SEARCH = 1; + + // Browse use case. Expects the traffic has an empty + // [query][google.cloud.retail.v2alpha.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_BROWSE = 2; +} + +// Metadata that is used to define a condition that triggers an action. +// A valid condition must specify at least one of 'query_terms' or +// 'products_filter'. If multiple fields are specified, the condition is met if +// all the fields are satisfied e.g. if a set of query terms and product_filter +// are set, then only items matching the product_filter for requests with a +// query matching the query terms wil get boosted. +message Condition { + // Query terms that we want to match on. + message QueryTerm { + // The value of the term to match on. + // Value cannot be empty. + // Value can have at most 3 terms if specified as a partial match. Each + // space separated string is considered as one term. + // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not + // allowed for partial match. + string value = 1; + + // Whether this is supposed to be a full or partial match. + bool full_match = 2; + } + + // Used for time-dependent conditions. + // Example: Want to have rule applied for week long sale. + message TimeRange { + // Start of time range. Range is inclusive. + google.protobuf.Timestamp start_time = 1; + + // End of time range. Range is inclusive. + google.protobuf.Timestamp end_time = 2; + } + + // A list (up to 10 entries) of terms to match the query on. If not + // specified, match all queries. + // If many query terms are specified, the condition + // is matched if any of the terms is a match (i.e. using the OR operator). + repeated QueryTerm query_terms = 1; + + // Range of time(s) specifying when Condition is active. + // Condition true if any time range matches. + repeated TimeRange active_time_range = 3; +} + +// A rule is a condition-action pair +// * A condition defines when a rule is to be triggered. +// * An action specifies what occurs on that trigger. +// Currently only boost rules are supported. +// Currently only supported by the search endpoint. +message Rule { + // A boost action to apply to results matching condition specified above. + message BoostAction { + // Strength of the condition boost, which must be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 1; + + // The filter can have a max size of 5000 characters. + // An expression which specifies which products to apply an action to. + // The syntax and supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string products_filter = 2; + } + + // * Rule Condition: + // - No [Condition][query_terms] provided is a global match. + // - 1 or more [Condition][query_terms] provided is combined with OR + // operator. + // * Action Input: The request query and filter that will be applied to the + // retrieved products, in addition to any filters already provided with the + // SearchRequest. The AND operator is used to combine the query's existing + // filters with the filter rule(s). NOTE: May result in 0 results when + // filters conflict. + // * Action Result: Filters the returned objects to be ONLY those that passed + // the filter. + message FilterAction { + // A filter to apply on the matching condition results. Supported features: + // + // * [filter][google.cloud.retail.v2alpha.Rule.FilterAction.filter] must be + // set. + // * Filter syntax is identical to + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]. + // See more + // details at the Retail Search + // [user guide](/retail/search/docs/filter-and-order#filter). + // * To filter products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string filter = 1; + } + + // Redirects a shopper to a specific page. + // * Rule Condition: + // - Must specify [Condition][query_terms]. + // * Action Input: Request Query + // * Action Result: Redirects shopper to provided uri. + message RedirectAction { + // URL must have length equal or less than 2000 characters. + string redirect_uri = 1; + } + + // Creates a set of terms that will be treated as synonyms of each other. + // Example: synonyms of "sneakers" and "shoes". + // * "sneakers" will use a synonym of "shoes". + // * "shoes" will use a synonym of "sneakers". + message TwowaySynonymsAction { + // Defines a set of synonyms. + // Can specify up to 100 synonyms. + // Must specify at least 2 synonyms. + repeated string synonyms = 1; + } + + // Maps a set of terms to a set of synonyms. + // Set of synonyms will be treated as synonyms of each query term only. + // `query_terms` will not be treated as synonyms of each other. + // Example: "sneakers" will use a synonym of "shoes". + // "shoes" will not use a synonym of "sneakers". + message OnewaySynonymsAction { + // Terms from the search query. + // Will treat synonyms as their synonyms. + // Not themselves synonyms of the synonyms. + // Can specify up to 100 terms. + repeated string query_terms = 3; + + // Defines a set of synonyms. + // Cannot contain duplicates. + // Can specify up to 100 synonyms. + repeated string synonyms = 4; + + // Will be [deprecated = true] post migration; + repeated string oneway_terms = 2; + } + + // Prevents `query_term` from being associated with specified terms during + // search. + // Example: Don't associate "gShoe" and "cheap". + message DoNotAssociateAction { + // Terms from the search query. + // Will not consider do_not_associate_terms for search if in search query. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Cannot contain duplicates or the query term. + // Can specify up to 100 terms. + repeated string do_not_associate_terms = 3; + + // Will be [deprecated = true] post migration; + repeated string terms = 1; + } + + // Replaces a term in the query. Multiple replacement candidates can be + // specified. All `query_terms` will be replaced with the replacement term. + // Example: Replace "gShoe" with "google shoe". + message ReplacementAction { + // Terms from the search query. + // Will be replaced by replacement term. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Term that will be used for replacement. + string replacement_term = 3; + + // Will be [deprecated = true] post migration; + string term = 1; + } + + // Prevents a term in the query from being used in search. + // Example: Don't search for "shoddy". + message IgnoreAction { + // Terms to ignore in the search query. + repeated string ignore_terms = 1; + } + + // An action must be provided. + oneof action { + // A boost action. + BoostAction boost_action = 2; + + // Redirects a shopper to a specific page. + RedirectAction redirect_action = 3; + + // Treats specific term as a synonym with a group of terms. + // Group of terms will not be treated as synonyms with the specific term. + OnewaySynonymsAction oneway_synonyms_action = 6; + + // Prevents term from being associated with other terms. + DoNotAssociateAction do_not_associate_action = 7; + + // Replaces specific terms in the query. + ReplacementAction replacement_action = 8; + + // Ignores specific terms from query during search. + IgnoreAction ignore_action = 9; + + // Filters results. + FilterAction filter_action = 10; + + // Treats a set of terms as synonyms of one another. + TwowaySynonymsAction twoway_synonyms_action = 11; + } + + // Required. The condition that triggers the rule. + // If the condition is empty, the rule will always apply. + Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// An intended audience of the [Product][google.cloud.retail.v2alpha.Product] +// for whom it's sold. +message Audience { + // The genders of the audience. Strongly encouraged to use the standard + // values: "male", "female", "unisex". + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [gender](https://support.google.com/merchants/answer/6324479). Schema.org + // property + // [Product.audience.suggestedGender](https://schema.org/suggestedGender). + repeated string genders = 1; + + // The age groups of the audience. Strongly encouraged to use the standard + // values: "newborn" (up to 3 months old), "infant" (3–12 months old), + // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically + // teens or older). + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [age_group](https://support.google.com/merchants/answer/6324463). + // Schema.org property + // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and + // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). + repeated string age_groups = 2; +} + +// The color information of a [Product][google.cloud.retail.v2alpha.Product]. +message ColorInfo { + // The standard color families. Strongly recommended to use the following + // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", + // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and + // "Mixed". Normally it is expected to have only 1 color family. May consider + // using single "Mixed" instead of multiple values. + // + // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string color_families = 1; + + // The color display names, which may be different from standard color family + // names, such as the color aliases used in the website frontend. Normally + // it is expected to have only 1 color. May consider using single "Mixed" + // instead of multiple values. + // + // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string colors = 2; +} + +// A custom attribute that is not explicitly modeled in +// [Product][google.cloud.retail.v2alpha.Product]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated double numbers = 2; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. + // + // Only set if type [text][google.cloud.retail.v2alpha.CustomAttribute.text] + // is set. Otherwise, a INVALID_ARGUMENT error is returned. + optional bool searchable = 3; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // indexed, so that it can be filtered, faceted or boosted in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter], + // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2alpha.SearchRequest.boost_spec] + // for more details. + optional bool indexable = 4; +} + +// Fulfillment information, such as the store IDs for in-store pickup or region +// IDs for different shipping methods. +message FulfillmentInfo { + // The fulfillment type, including commonly used types (such as pickup in + // store and same day delivery), and custom types. Customers have to map + // custom types to their display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + string type = 1; + + // The IDs for this [type][google.cloud.retail.v2alpha.FulfillmentInfo.type], + // such as the store IDs for + // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // or the region IDs for + // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2alpha.FulfillmentInfo.type]. + // + // A maximum of 3000 values are allowed. Each value must be a string with a + // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such + // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string place_ids = 2; +} + +// [Product][google.cloud.retail.v2alpha.Product] image. Recommendations AI and +// Retail Search do not use product images to improve prediction and search +// results. However, product images can be returned in results, and are shown in +// prediction or search previews in the console. +message Image { + // Required. URI of the image. + // + // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Height of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 height = 2; + + // Width of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 width = 3; +} + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are set, then + // the lower bound is negative infinity. + // + // This field must be not larger than + // [max][google.cloud.retail.v2alpha.Interval.max]. Otherwise, an + // INVALID_ARGUMENT error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are set, then + // the upper bound is positive infinity. + // + // This field must be not smaller than + // [min][google.cloud.retail.v2alpha.Interval.min]. Otherwise, an + // INVALID_ARGUMENT error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// The price information of a [Product][google.cloud.retail.v2alpha.Product]. +message PriceInfo { + // The price range of all + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. + message PriceRange { + // The inclusive + // [Product.pricing_info.price][google.cloud.retail.v2alpha.PriceInfo.price] + // interval of all + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. + Interval price = 1; + + // The inclusive + // [Product.pricing_info.original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] + // internal of all + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. + Interval original_price = 2; + } + + // The 3-letter currency code defined in [ISO + // 4217](https://www.iso.org/iso-4217-currency-codes.html). + // + // If this field is an unrecognizable currency code, an INVALID_ARGUMENT + // error is returned. + // + // The + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s with the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] + // must share the same + // [currency_code][google.cloud.retail.v2alpha.PriceInfo.currency_code]. + // Otherwise, a FAILED_PRECONDITION error is returned. + string currency_code = 1; + + // Price of the product. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). Schema.org + // property [Offer.price](https://schema.org/price). + float price = 2; + + // Price of the product without any discount. If zero, by default set to be + // the [price][google.cloud.retail.v2alpha.PriceInfo.price]. + float original_price = 3; + + // The costs associated with the sale of a particular product. Used for gross + // profit reporting. + // + // * Profit = [price][google.cloud.retail.v2alpha.PriceInfo.price] - + // [cost][google.cloud.retail.v2alpha.PriceInfo.cost] + // + // Google Merchant Center property + // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). + float cost = 4; + + // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] + // starts to be effective. This can be set as a future timestamp, and the + // [price][google.cloud.retail.v2alpha.PriceInfo.price] is only used for + // search after + // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. + // If so, the + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is + // used before + // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. + // + // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is + // always effective because it will cause additional latency during search. + google.protobuf.Timestamp price_effective_time = 5; + + // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] + // stops to be effective. The + // [price][google.cloud.retail.v2alpha.PriceInfo.price] is used for search + // before + // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. + // If this field is set, the + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is + // used after + // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. + // + // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is + // always effective because it will cause additional latency during search. + google.protobuf.Timestamp price_expire_time = 6; + + // Output only. The price range of all the child + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s grouped together on the + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]. Only populated for + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. + // Do not set this field in API requests. + PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The rating of a [Product][google.cloud.retail.v2alpha.Product]. +message Rating { + // The total number of ratings. This value is independent of the value of + // [rating_histogram][google.cloud.retail.v2alpha.Rating.rating_histogram]. + // + // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 rating_count = 1; + + // The average rating of the [Product][google.cloud.retail.v2alpha.Product]. + // + // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is + // returned. + float average_rating = 2; + + // List of rating counts per rating value (index = rating - 1). The list is + // empty if there is no rating. If the list is non-empty, its size is + // always 5. Otherwise, an INVALID_ARGUMENT error is returned. + // + // For example, [41, 14, 13, 47, 303]. It means that the + // [Product][google.cloud.retail.v2alpha.Product] got 41 ratings with 1 star, + // 14 ratings with 2 star, and so on. + repeated int32 rating_histogram = 3; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. + // + // Always use a hashed value for this ID. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string user_id = 1; + + // The end user's IP address. This field is used to extract location + // information for personalization. + // + // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 + // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This should not be set when: + // + // * setting + // [SearchRequest.user_info][google.cloud.retail.v2alpha.SearchRequest.user_info]. + // * using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] + // is set. + string ip_address = 2; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][google.cloud.retail.v2alpha.SearchResponse.sponsored_results]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] + // is set. + string user_agent = 3; + + // True if the request is made directly from the end user, in which case the + // [ip_address][google.cloud.retail.v2alpha.UserInfo.ip_address] and + // [user_agent][google.cloud.retail.v2alpha.UserInfo.user_agent] can be + // populated from the HTTP request. This flag should be set only if the API + // request is made directly from the end user such as a mobile app (and not if + // a gateway or a server is processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent]. + bool direct_user_request = 4; +} + +// The inventory information at a place (e.g. a store) identified +// by a place ID. +message LocalInventory { + // The place ID for the current set of inventory information. + string place_id = 1; + + // Product price and cost information. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 2; + + // Additional local inventory attributes, for example, store name, promotion + // tags, etc. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * At most 30 attributes are allowed. + // * The key must be a UTF-8 encoded string with a length limit of 32 + // characters. + // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, + // key0LikeThis or KEY_1_LIKE_THIS. + // * The attribute values must be of the same type (text or number). + // * Only 1 value is allowed for each attribute. + // * For text values, the length limit is 256 UTF-8 characters. + // * The attribute does not support search. The `searchable` field should be + // unset or set to false. + // * The max summed total bytes of custom attribute keys and values per + // product is 5MiB. + map attributes = 3; + + // Input only. Supported fulfillment types. Valid fulfillment type values + // include commonly used types (such as pickup in store and same day + // delivery), and custom types. Customers have to map custom types to their + // display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string fulfillment_types = 4 + [(google.api.field_behavior) = INPUT_ONLY]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto new file mode 100644 index 00000000..a91aa618 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto @@ -0,0 +1,199 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Auto-completion service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service CompletionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified prefix with keyword suggestions. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }; + } + + // Bulk import of processed completion dataset. + // + // Request processing is asynchronous. Partial updating is not supported. + // + // The operation is successfully finished only after the imported suggestions + // are indexed successfully and ready for serving. The process takes hours. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc ImportCompletionData(ImportCompletionDataRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/completionData:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.ImportCompletionDataResponse" + metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" + }; + } +} + +// Auto-complete parameters. +message CompleteQueryRequest { + // Required. Catalog for which the completion is performed. + // + // Full resource name of catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The query used to generate suggestions. + // + // The maximum number of allowed characters is 255. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required field. A unique identifier for tracking visitors. For example, + // this could be implemented with an HTTP cookie, which should be able to + // uniquely identify a visitor on a single device. This unique identifier + // should not change if the visitor logs in or out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 7; + + // The language filters applied to the output suggestions. If set, it should + // contain the language of the query. If not set, suggestions are returned + // without considering language restrictions. This is the BCP-47 language + // code, such as "en-US" or "sr-Latn". For more information, see [Tags for + // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + // number of language codes is 3. + repeated string language_codes = 3; + + // The device type context for completion suggestions. + // It is useful to apply different suggestions on different device types, e.g. + // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + // types. + // + // Supported formats: + // + // * `UNKNOWN_DEVICE_TYPE` + // + // * `DESKTOP` + // + // * `MOBILE` + // + // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + string device_type = 4; + + // Determines which dataset to use for fetching completion. "user-data" will + // use the imported dataset through + // [CompletionService.ImportCompletionData][google.cloud.retail.v2alpha.CompletionService.ImportCompletionData]. + // "cloud-retail" will use the dataset generated by cloud retail based on user + // events. If leave empty, it will use the "user-data". + // + // Current supported values: + // + // * user-data + // + // * cloud-retail + // This option requires additional allowlisting. Before using cloud-retail, + // contact Cloud Retail support team first. + string dataset = 6; + + // Completion max suggestions. If left unset or set to 0, then will fallback + // to the configured value + // [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions]. + // + // The maximum allowed max suggestions is 20. If it is set higher, it will be + // capped by 20. + int32 max_suggestions = 5; +} + +// Response of the auto-complete query. +message CompleteQueryResponse { + // Resource that represents completion results. + message CompletionResult { + // The suggestion for the query. + string suggestion = 1; + + // Custom attributes for the suggestion term. + // * For "user-data", the attributes are additional custom attributes + // ingested through BigQuery. + // * For "cloud-retail", the attributes are product attributes generated + // by Cloud Retail. + map attributes = 2; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Results of the matching suggestions. The result list is ordered and the + // first result is top suggestion. + repeated CompletionResult completion_results = 1; + + // A unique complete token. This should be included in the + // [UserEvent.completion_detail][google.cloud.retail.v2alpha.UserEvent.completion_detail] + // for search events resulting from this completion, which enables accurate + // attribution of complete model performance. + string attribution_token = 2; + + // Matched recent searches of this user. The maximum number of recent searches + // is 10. This field is a restricted feature. Contact Retail Search support + // team if you are interested in enabling it. + // + // This feature is only available when + // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2alpha.CompleteQueryRequest.visitor_id] + // field is set and [UserEvent][google.cloud.retail.v2alpha.UserEvent] is + // imported. The recent searches satisfy the follow rules: + // * They are ordered from latest to oldest. + // * They are matched with + // [CompleteQueryRequest.query][google.cloud.retail.v2alpha.CompleteQueryRequest.query] + // case insensitively. + // * They are transformed to lower cases. + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto new file mode 100644 index 00000000..4d85015e --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto @@ -0,0 +1,92 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configures dynamic serving time metadata that is used to pre and post +// process search/recommendation model results. +message Control { + option (google.api.resource) = { + type: "retail.googleapis.com/Control" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }; + + // The behavior/type of the control + // + // A behavior/type must be specified on creation. Type cannot be changed once + // specified (e.g. A Rule control will always be a Rule control.). An + // INVALID_ARGUMENT will be returned if either condition is violated. + oneof control { + // A facet specification to perform faceted search. + SearchRequest.FacetSpec facet_spec = 3; + + // A rule control - a condition-action pair. + // Enacts a set action when the condition is triggered. + // For example: Boost "gShoe" when query full matches "Running Shoes". + Rule rule = 4; + } + + // Immutable. Fully qualified name + // projects/*/locations/global/catalogs/*/controls/* + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable control display name. Used in Retail UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is thrown. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Output only. List of serving configuration ids that that are associated + // with this control. Note the association is managed via the ServingConfig, + // this is an output only denormalizeed view. Assumed to be in the same + // catalog. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the serving config is used + // for. Currently we support setting only one type of solution at creation + // time. + // + // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. + // If no solution type is provided at creation time, will default to + // SOLUTION_TYPE_SEARCH. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Specifies the use case for the control. + // Affects what condition fields can be set. + // Only settable by search controls. + // Will default to SEARCH_SOLUTION_USE_CASE_SEARCH if not specified. + // Currently only allow one search_solution_use_case per control. + repeated SearchSolutionUseCase search_solution_use_case = 7 + [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto new file mode 100644 index 00000000..6372aca6 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto @@ -0,0 +1,184 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/control.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for modifying Control. +service ControlService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a Control. + // + // If the [Control][google.cloud.retail.v2alpha.Control] to create already + // exists, an ALREADY_EXISTS error is returned. + rpc CreateControl(CreateControlRequest) returns (Control) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" + body: "control" + }; + option (google.api.method_signature) = "parent,control,control_id"; + } + + // Deletes a Control. + // + // If the [Control][google.cloud.retail.v2alpha.Control] to delete does not + // exist, a NOT_FOUND error is returned. + rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Control. + // + // [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different + // oneof field, if so an INVALID_ARGUMENT is returned. If the + // [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a + // NOT_FOUND error is returned. + rpc UpdateControl(UpdateControlRequest) returns (Control) { + option (google.api.http) = { + patch: "/v2alpha/{control.name=projects/*/locations/*/catalogs/*/controls/*}" + body: "control" + }; + option (google.api.method_signature) = "control,update_mask"; + } + + // Gets a Control. + rpc GetControl(GetControlRequest) returns (Control) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all Controls linked to this catalog. + rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request for CreateControl method. +message CreateControlRequest { + // Required. Full resource name of parent catalog. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The Control to create. + Control control = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the Control, which will become the final + // component of the Control's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string control_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateControl method. +message UpdateControlRequest { + // Required. The Control to update. + Control control = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Control][google.cloud.retail.v2alpha.Control] to update. The following are + // NOT supported: + // + // * [Control.name][google.cloud.retail.v2alpha.Control.name] + // + // If not set or empty, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteControl method. +message DeleteControlRequest { + // Required. The resource name of the Control to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for GetControl method. +message GetControlRequest { + // Required. The resource name of the Control to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for ListControls method. +message ListControlsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 50. Max allowed value is 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListControls` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2alpha.ListControlsRequest.filter] is unset. + // * List controls that are used in a single ServingConfig: + // 'serving_config = "boosted_home_page_cvr"' + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListControls method. +message ListControlsResponse { + // All the Controls for a given catalog. + repeated Control controls = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto new file mode 100644 index 00000000..f29c7f9a --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto @@ -0,0 +1,77 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ExportConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configuration of destination for Export related errors. +message ExportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage path for import errors. This must be an empty, + // existing Cloud Storage bucket. Export errors will be written to a file in + // this bucket, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Metadata related to the progress of the Export operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ExportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Response of the ExportProductsRequest. If the long running +// operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ExportErrorsConfig errors_config = 2; +} + +// Response of the ExportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ExportErrorsConfig errors_config = 2; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto new file mode 100644 index 00000000..a1fcf240 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto @@ -0,0 +1,397 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/cloud/retail/v2alpha/user_event.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Google Cloud Storage location for input content. +// format. +message GcsSource { + // Required. Google Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. A request can + // contain at most 100 files, and each file can be up to 2 GB. See + // [Importing product + // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) + // for the expected file format and setup instructions. + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. + // * `user_event_ga360`: Using + // https://support.google.com/analytics/answer/3437719. + // + // Supported values for control imports: + // + // * 'control' (default): One JSON + // [Control][google.cloud.retail.v2alpha.Control] per line. + // + // Supported values for catalog attribute imports: + // + // * 'catalog_attribute' (default): One CSV + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + google.type.Date partition_date = 6; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 5; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 3; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. + // * `user_event_ga360`: + // The schema is available here: + // https://support.google.com/analytics/answer/3437719. + // * `user_event_ga4`: This feature is in private preview. Please contact the + // support team for importing Google Analytics 4 events. + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for auto-completion imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + string data_schema = 4; +} + +// The inline source for the input config for ImportProducts method. +message ProductInlineSource { + // Required. A list of products to update/create. Each product must have a + // valid [Product.id][google.cloud.retail.v2alpha.Product.id]. Recommended max + // of 100 items. + repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The inline source for the input config for ImportUserEvents method. +message UserEventInlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configuration of destination for Import related errors. +message ImportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors will be written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for Import methods. +message ImportProductsRequest { + // Indicates how imported products are reconciled with the existing products + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new products or updates existing products. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire product dataset. Existing + // products may be deleted if they are not present in the source location. + // + // Can only be set while using + // [BigQuerySource][google.cloud.retail.v2alpha.BigQuerySource]. And the + // BigQuery dataset must be created in the data location "us (multiple + // regions in United States)", otherwise a PERMISSION_DENIED error is + // thrown. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + FULL = 2; + } + + // Required. + // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + // + // If no updateMask is specified, requires products.create permission. + // If updateMask is specified, requires products.update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Deprecated. This field has no effect. + string request_id = 6 [deprecated = true]; + + // Required. The desired input location of the data. + ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. + ImportErrorsConfig errors_config = 3; + + // Indicates which fields in the provided imported 'products' to update. If + // not set, will by default update all fields. + google.protobuf.FieldMask update_mask = 4; + + // The mode of reconciliation between existing products and the products to be + // imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 5; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + string notification_pubsub_topic = 7; +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // Required. `projects/1234/locations/global/catalogs/default_catalog` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + UserEventInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorsConfig errors_config = 3; +} + +// Request message for ImportCompletionData methods. +message ImportCompletionDataRequest { + // Required. The catalog which the suggestions dataset belongs to. + // + // Format: `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + CompletionDataInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 3; +} + +// The input config source for products. +message ProductInputConfig { + // Required. The source of the input. + oneof source { + // The Inline source for the input content for products. + ProductInlineSource product_inline_source = 1; + + // Google Cloud Storage location for the input content. + GcsSource gcs_source = 2; + + // BigQuery input source. + BigQuerySource big_query_source = 3; + } +} + +// The input config source for user events. +message UserEventInputConfig { + // The source of the input. + oneof source { + // Required. The Inline source for the input content for UserEvents. + UserEventInlineSource user_event_inline_source = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Google Cloud Storage location for the input content. + GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource big_query_source = 3 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// The input config source for completion data. +message CompletionDataInputConfig { + // The source of the input. + // + // Supported + // [BigQuerySource.data_schema][google.cloud.retail.v2alpha.BigQuerySource.data_schema] + // values for suggestions imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + oneof source { + // Required. BigQuery input source. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + BigQuerySource big_query_source = 1 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// Metadata related to the progress of the Import operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ImportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; + + // Deprecated. This field is never set. + string request_id = 5 [deprecated = true]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; +} + +// Response of the +// [ImportProductsRequest][google.cloud.retail.v2alpha.ImportProductsRequest]. +// If the long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorsConfig errors_config = 2; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorsConfig errors_config = 2; + + // Aggregated statistics of user event import status. + UserEventImportSummary import_summary = 3; +} + +// A summary of import result. The UserEventImportSummary summarizes +// the import status for user events. +message UserEventImportSummary { + // Count of user events imported with complete existing catalog information. + int64 joined_events_count = 1; + + // Count of user events imported, but with catalog information not found + // in the imported catalog. + int64 unjoined_events_count = 2; +} + +// Response of the +// [ImportCompletionDataRequest][google.cloud.retail.v2alpha.ImportCompletionDataRequest]. +// If the long running operation is done, this message is returned by the +// google.longrunning.Operations.response field if the operation is successful. +message ImportCompletionDataResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto new file mode 100644 index 00000000..5b89bceb --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto @@ -0,0 +1,194 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2alpha/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "PredictionServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for making recommendation prediction. +service PredictionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation prediction. + rpc Predict(PredictRequest) returns (PredictResponse) { + option (google.api.http) = { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" + body: "*" + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} + // The ID of the Recommendations AI placement. Before you can request + // predictions from your model, you must create at least one placement for it. + // For more information, see [Managing + // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + // + // The full list of available placements can be seen at + // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the predict request. Note that this user event detail + // won't be ingested to userEvent logs. Thus, a separate userEvent write + // request is required for event logging. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return per page. Set this property + // to the number of prediction results needed. If zero, the service will + // choose a reasonable default. The maximum allowed value is 100. Values + // above 100 will be coerced to 100. + int32 page_size = 3; + + // The previous PredictResponse.next_page_token. + string page_token = 4; + + // Filter for restricting prediction results with a length limit of 5,000 + // characters. Accepts values for tags and the `filterOutOfStockItems` flag. + // + // * Tag expressions. Restricts predictions to products that match all of the + // specified tags. Boolean operators `OR` and `NOT` are supported if the + // expression is enclosed in parentheses, and must be separated from the + // tag values by a space. `-"tagA"` is also supported and is equivalent to + // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + // with a size limit of 1,000 characters. + // + // Note: "Recently viewed" models don't support tag filtering at the + // moment. + // + // * filterOutOfStockItems. Restricts predictions to products that do not + // have a + // stockState value of OUT_OF_STOCK. + // + // Examples: + // + // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + // * filterOutOfStockItems tag=(-"promotional") + // * filterOutOfStockItems + // + // If your filter blocks all prediction results, the API will return generic + // (unfiltered) popular products. If you only want results strictly matching + // the filters, set `strictFiltering` to True in `PredictRequest.params` to + // receive empty results instead. + // Note that the API will never return items with storageStatus of "EXPIRED" + // or "DELETED" regardless of filter choices. + string filter = 5; + + // Use validate only mode for this prediction query. If set to true, a + // dummy model will be used that returns arbitrary products. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 6; + + // Additional domain specific parameters for the predictions. + // + // Allowed values: + // + // * `returnProduct`: Boolean. If set to true, the associated product + // object will be returned in the `results.metadata` field in the + // prediction response. + // * `returnScore`: Boolean. If set to true, the prediction 'score' + // corresponding to each returned product will be set in the + // `results.metadata` field in the prediction response. The given + // 'score' indicates the probability of an product being clicked/purchased + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular products instead of empty if + // your filter blocks all prediction results. + // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-price-reranking', 'low-price-reranking', + // 'medium-price-reranking', 'high-price-reranking'}. This gives + // request-level control and adjusts prediction results based on product + // price. + // * `diversityLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-diversity', 'low-diversity', + // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + // request-level control and adjusts prediction results based on product + // category. + map params = 7; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters, and cannot be empty. Values can be empty, and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 8; +} + +// Response message for predict method. +message PredictResponse { + // PredictionResult represents the recommendation prediction results. + message PredictionResult { + // ID of the recommended product + string id = 1; + + // Additional product metadata / annotations. + // + // Possible values: + // + // * `product`: JSON representation of the product. Will be set if + // `returnProduct` is set to true in `PredictRequest.params`. + // * `score`: Prediction score in double value. Will be set if + // `returnScore` is set to true in `PredictRequest.params`. + map metadata = 2; + } + + // A list of recommended products. The order represents the ranking (from the + // most relevant product to the least). + repeated PredictionResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this + // recommendation, which enables accurate attribution of recommendation model + // performance. + string attribution_token = 2; + + // IDs of products in the request that were missing from the inventory. + repeated string missing_ids = 3; + + // True if the validateOnly property was set in the request. + bool validate_only = 4; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto new file mode 100644 index 00000000..cbadc568 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto @@ -0,0 +1,567 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/promotion.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" +}; + +// Product captures all metadata information of items to be recommended or +// searched. +message Product { + option (google.api.resource) = { + type: "retail.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }; + + // The type of this product. + enum Type { + // Default value. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] + // if unset. + TYPE_UNSPECIFIED = 0; + + // The primary type. + // + // As the primary unit for predicting, indexing and search serving, a + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] is grouped with multiple + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s. + PRIMARY = 1; + + // The variant type. + // + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s usually share some common + // attributes on the same + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s, but they have variant + // attributes like different colors, sizes and prices, etc. + VARIANT = 2; + + // The collection type. Collection products are bundled + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s or + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s that are sold together, + // such as a jewelry set with necklaces, earrings and rings, etc. + COLLECTION = 3; + } + + // Product availability. If this field is unspecified, the product is + // assumed to be in stock. + enum Availability { + // Default product availability. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK] + // if unset. + AVAILABILITY_UNSPECIFIED = 0; + + // Product in stock. + IN_STOCK = 1; + + // Product out of stock. + OUT_OF_STOCK = 2; + + // Product that is in pre-order state. + PREORDER = 3; + + // Product that is back-ordered (i.e. temporarily out of stock). + BACKORDER = 4; + } + + oneof expiration { + // The timestamp when this product becomes unavailable for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // If it is set, the [Product][google.cloud.retail.v2alpha.Product] is not + // available for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // after [expire_time][google.cloud.retail.v2alpha.Product.expire_time]. + // However, the product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] must be + // later than + // [available_time][google.cloud.retail.v2alpha.Product.available_time] and + // [publish_time][google.cloud.retail.v2alpha.Product.publish_time], + // otherwise an INVALID_ARGUMENT error is thrown. + // + // Corresponding properties: Google Merchant Center property + // [expiration_date](https://support.google.com/merchants/answer/6324499). + google.protobuf.Timestamp expire_time = 16; + + // Input only. The TTL (time to live) of the product. + // + // If it is set, it must be a non-negative value, and + // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is set as + // current timestamp plus [ttl][google.cloud.retail.v2alpha.Product.ttl]. + // The derived + // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is + // returned in the output and [ttl][google.cloud.retail.v2alpha.Product.ttl] + // is left blank when retrieving the + // [Product][google.cloud.retail.v2alpha.Product]. + // + // If it is set, the product is not available for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // after current timestamp plus + // [ttl][google.cloud.retail.v2alpha.Product.ttl]. However, the product can + // still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + google.protobuf.Duration ttl = 17 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Immutable. Full resource name of the product, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. [Product][google.cloud.retail.v2alpha.Product] identifier, which + // is the final component of [name][google.cloud.retail.v2alpha.Product.name]. + // For example, this field is "id_1", if + // [name][google.cloud.retail.v2alpha.Product.name] is + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [id](https://support.google.com/merchants/answer/6324405). Schema.org + // property [Product.sku](https://schema.org/sku). + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The type of the product. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] + // if unset. + Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Variant group identifier. Must be an + // [id][google.cloud.retail.v2alpha.Product.id], with the same parent branch + // with this product. Otherwise, an error is thrown. + // + // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s, this field can only be + // empty or set to the same value as + // [id][google.cloud.retail.v2alpha.Product.id]. + // + // For VARIANT [Product][google.cloud.retail.v2alpha.Product]s, this field + // cannot be empty. A maximum of 2,000 products are allowed to share the same + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [item_group_id](https://support.google.com/merchants/answer/6324507). + // Schema.org property + // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). + string primary_product_id = 4; + + // The [id][google.cloud.retail.v2alpha.Product.id] of the collection members + // when [type][google.cloud.retail.v2alpha.Product.type] is + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]. + // + // Non-existent product ids are allowed. + // The [type][google.cloud.retail.v2alpha.Product.type] of the members must be + // either [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] or + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] otherwise + // and INVALID_ARGUMENT error is thrown. Should not set it for other types. A + // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is + // return. + repeated string collection_member_ids = 5; + + // The Global Trade Item Number (GTIN) of the product. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Corresponding properties: Google Merchant Center property + // [gtin](https://support.google.com/merchants/answer/6324461). + // Schema.org property + // [Product.isbn](https://schema.org/isbn), + // [Product.gtin8](https://schema.org/gtin8), + // [Product.gtin12](https://schema.org/gtin12), + // [Product.gtin13](https://schema.org/gtin13), or + // [Product.gtin14](https://schema.org/gtin14). + // + // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. + string gtin = 6; + + // Product categories. This field is repeated for supporting one product + // belonging to several parallel categories. Strongly recommended using the + // full path for better search / recommendation quality. + // + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // For example, if a shoes product belongs to both + // ["Shoes & Accessories" -> "Shoes"] and + // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be + // represented as: + // + // "categories": [ + // "Shoes & Accessories > Shoes", + // "Sports & Fitness > Athletic Clothing > Shoes" + // ] + // + // Must be set for + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] otherwise an + // INVALID_ARGUMENT error is returned. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [google_product_category][mc_google_product_category]. Schema.org property + // [Product.category] (https://schema.org/category). + // + // [mc_google_product_category]: + // https://support.google.com/merchants/answer/6324436 + repeated string categories = 7; + + // Required. Product title. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [title](https://support.google.com/merchants/answer/6324415). Schema.org + // property [Product.name](https://schema.org/name). + string title = 8 [(google.api.field_behavior) = REQUIRED]; + + // The brands of the product. + // + // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded + // string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [brand](https://support.google.com/merchants/answer/6324351). Schema.org + // property [Product.brand](https://schema.org/brand). + repeated string brands = 9; + + // Product description. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [description](https://support.google.com/merchants/answer/6324468). + // Schema.org property [Product.description](https://schema.org/description). + string description = 10; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // + // For product prediction, this field is ignored and the model automatically + // detects the text language. The + // [Product][google.cloud.retail.v2alpha.Product] can include text in + // different languages, but duplicating + // [Product][google.cloud.retail.v2alpha.Product]s to provide text in multiple + // languages can result in degraded model performance. + // + // For product search this field is in use. It defaults to "en-US" if unset. + string language_code = 11; + + // Highly encouraged. Extra product attributes to be included. For example, + // for products, this could include the store name, vendor, style, color, etc. + // These are very strong signals for recommendation model, thus we highly + // recommend providing the attributes here. + // + // Features that can take on one of a limited number of possible values. Two + // types of features can be set are: + // + // Textual features. some examples would be the brand/maker of a product, or + // country of a customer. Numerical features. Some examples would be the + // height/weight of a product, or age of a customer. + // + // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, + // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} + // }`. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * Max entries count: 200. + // * The key must be a UTF-8 encoded string with a length limit of 128 + // characters. + // * For indexable attribute, the key must match the pattern: + // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or + // `KEY_1_LIKE_THIS`. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a non-empty UTF-8 encoded string with a + // length limit of 256 characters. + // * For number attributes, at most 400 values are allowed. + map attributes = 12; + + // Custom tags associated with the product. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. This value must be a UTF-8 + // encoded string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This tag can be used for filtering recommendation results by passing the + // tag as part of the + // [PredictRequest.filter][google.cloud.retail.v2alpha.PredictRequest.filter]. + // + // Corresponding properties: Google Merchant Center property + // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). + repeated string tags = 13; + + // Product price and cost information. + // + // Corresponding properties: Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 14; + + // The rating of this product. + Rating rating = 15; + + // The timestamp when this [Product][google.cloud.retail.v2alpha.Product] + // becomes available for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + google.protobuf.Timestamp available_time = 18; + + // The online availability of the + // [Product][google.cloud.retail.v2alpha.Product]. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK]. + // + // Corresponding properties: Google Merchant Center property + // [availability](https://support.google.com/merchants/answer/6324448). + // Schema.org property [Offer.availability](https://schema.org/availability). + Availability availability = 19; + + // The available quantity of the item. + google.protobuf.Int32Value available_quantity = 20; + + // Fulfillment information, such as the store IDs for in-store pickup or + // region IDs for different shipping methods. + // + // All the elements must have distinct + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated FulfillmentInfo fulfillment_info = 21; + + // Canonical URL directly linking to the product detail page. + // + // It is strongly recommended to provide a valid uri for the product, + // otherwise the service performance could be significantly degraded. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [link](https://support.google.com/merchants/answer/6324416). Schema.org + // property [Offer.url](https://schema.org/url). + string uri = 22; + + // Product images for the product. We highly recommend putting the main + // image first. + // + // A maximum of 300 images are allowed. + // + // Corresponding properties: Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + repeated Image images = 23; + + // The target group associated with a given audience (e.g. male, veterans, + // car owners, musicians, etc.) of the product. + Audience audience = 24; + + // The color of the product. + // + // Corresponding properties: Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + ColorInfo color_info = 25; + + // The size of the product. To represent different size systems or size types, + // consider using this format: [[[size_system:]size_type:]size_value]. + // + // For example, in "US:MENS:M", "US" represents size system; "MENS" represents + // size type; "M" represents size value. In "GIRLS:27", size system is empty; + // "GIRLS" represents size type; "27" represents size value. In "32 inches", + // both size system and size type are empty, while size value is "32 inches". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [size](https://support.google.com/merchants/answer/6324492), + // [size_type](https://support.google.com/merchants/answer/6324497), and + // [size_system](https://support.google.com/merchants/answer/6324502). + // Schema.org property [Product.size](https://schema.org/size). + repeated string sizes = 26; + + // The material of the product. For example, "leather", "wooden". + // + // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 200 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [material](https://support.google.com/merchants/answer/6324410). Schema.org + // property [Product.material](https://schema.org/material). + repeated string materials = 27; + + // The pattern or graphic print of the product. For example, "striped", "polka + // dot", "paisley". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org + // property [Product.pattern](https://schema.org/pattern). + repeated string patterns = 28; + + // The condition of the product. Strongly encouraged to use the standard + // values: "new", "refurbished", "used". + // + // A maximum of 1 value is allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [condition](https://support.google.com/merchants/answer/6324469). + // Schema.org property + // [Offer.itemCondition](https://schema.org/itemCondition). + repeated string conditions = 29; + + // The promotions applied to the product. A maximum of 10 values are allowed + // per [Product][google.cloud.retail.v2alpha.Product]. Only + // [Promotion.promotion_id][google.cloud.retail.v2alpha.Promotion.promotion_id] + // will be used, other fields will be ignored if set. + repeated Promotion promotions = 34; + + // The timestamp when the product is published by the retailer for the first + // time, which indicates the freshness of the products. Note that this field + // is different from + // [available_time][google.cloud.retail.v2alpha.Product.available_time], given + // it purely describes product freshness regardless of when it is available on + // search and recommendation. + google.protobuf.Timestamp publish_time = 33; + + // Indicates which fields in the + // [Product][google.cloud.retail.v2alpha.Product]s are returned in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse]. + // + // Supported fields for all [type][google.cloud.retail.v2alpha.Product.type]s: + // + // * [audience][google.cloud.retail.v2alpha.Product.audience] + // * [availability][google.cloud.retail.v2alpha.Product.availability] + // * [brands][google.cloud.retail.v2alpha.Product.brands] + // * [color_info][google.cloud.retail.v2alpha.Product.color_info] + // * [conditions][google.cloud.retail.v2alpha.Product.conditions] + // * [gtin][google.cloud.retail.v2alpha.Product.gtin] + // * [materials][google.cloud.retail.v2alpha.Product.materials] + // * [name][google.cloud.retail.v2alpha.Product.name] + // * [patterns][google.cloud.retail.v2alpha.Product.patterns] + // * [price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [rating][google.cloud.retail.v2alpha.Product.rating] + // * [sizes][google.cloud.retail.v2alpha.Product.sizes] + // * [title][google.cloud.retail.v2alpha.Product.title] + // * [uri][google.cloud.retail.v2alpha.Product.uri] + // + // Supported fields only for + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]: + // + // * [categories][google.cloud.retail.v2alpha.Product.categories] + // * [description][google.cloud.retail.v2alpha.Product.description] + // * [images][google.cloud.retail.v2alpha.Product.images] + // + // Supported fields only for + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]: + // + // * Only the first image in + // [images][google.cloud.retail.v2alpha.Product.images] + // + // To mark [attributes][google.cloud.retail.v2alpha.Product.attributes] as + // retrievable, include paths of the form "attributes.key" where "key" is the + // key of a custom attribute, as specified in + // [attributes][google.cloud.retail.v2alpha.Product.attributes]. + // + // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], the + // following fields are always returned in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] by default: + // + // * [name][google.cloud.retail.v2alpha.Product.name] + // + // For [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT], the + // following fields are always returned in by default: + // + // * [name][google.cloud.retail.v2alpha.Product.name] + // * [color_info][google.cloud.retail.v2alpha.Product.color_info] + // + // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] may increase + // response payload size and serving latency. + google.protobuf.FieldMask retrievable_fields = 30; + + // Output only. Product variants grouped together on primary product which + // share similar product attributes. It's automatically grouped by + // [primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] + // for all the product variants. Only populated for + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. + // Do not set this field in API requests. + repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto new file mode 100644 index 00000000..7bced3fb --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto @@ -0,0 +1,882 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/cloud/retail/v2alpha/purge_config.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for ingesting [Product][google.cloud.retail.v2alpha.Product] +// information of the customer's website. +service ProductService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Product][google.cloud.retail.v2alpha.Product]. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Gets a [Product][google.cloud.retail.v2alpha.Product]. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Product][google.cloud.retail.v2alpha.Product]s. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a [Product][google.cloud.retail.v2alpha.Product]. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v2alpha/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Deletes a [Product][google.cloud.retail.v2alpha.Product]. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Permanently deletes all selected + // [Product][google.cloud.retail.v2alpha.Product]s under a branch. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed offline. Depending on the number of + // [Product][google.cloud.retail.v2alpha.Product]s, this operation could take + // hours to complete. Before the operation completes, some + // [Product][google.cloud.retail.v2alpha.Product]s may still be returned by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, + // this operation could take hours to complete. To get a sample of + // [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set + // [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] + // to false. + rpc PurgeProducts(PurgeProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.PurgeProductsResponse" + metadata_type: "google.cloud.retail.v2alpha.PurgeProductsMetadata" + }; + } + + // Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. + // + // Request processing may be synchronous. No partial updating is supported. + // Non-existing items are created. + // + // Note that it is possible for a subset of the + // [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated. + rpc ImportProducts(ImportProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.ImportProductsResponse" + metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" + }; + } + + // Updates inventory information for a + // [Product][google.cloud.retail.v2alpha.Product] while respecting the last + // update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, updates are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // When inventory is updated with + // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], + // the specified inventory field value(s) will overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update time for the specified inventory fields will be overwritten to the + // time of the + // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // or + // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // request. + // + // If no inventory fields are set in + // [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], + // then any pre-existing inventory information for this product will be used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], + // then any existing inventory information will be preserved. + // + // Pre-existing inventory information can only be updated with + // [SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], + // [AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], + // and + // [RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" + body: "*" + }; + option (google.api.method_signature) = "inventory,set_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.SetInventoryResponse" + metadata_type: "google.cloud.retail.v2alpha.SetInventoryMetadata" + }; + } + + // Incrementally adds place IDs to + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the added place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata" + }; + } + + // Incrementally removes place IDs from a + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the removed place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata" + }; + } + + // Updates local inventory information for a + // [Product][google.cloud.retail.v2alpha.Product] at a list of places, while + // respecting the last update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // inventory information. If the request is valid, the update will be enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddLocalInventories(AddLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.AddLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2alpha.AddLocalInventoriesMetadata" + }; + } + + // Remove local inventory information for a + // [Product][google.cloud.retail.v2alpha.Product] at a list of places at a + // removal timestamp. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, removals are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata" + }; + } +} + +// Request message for [CreateProduct][] method. +message CreateProductRequest { + // Required. The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The [Product][google.cloud.retail.v2alpha.Product] to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Product][google.cloud.retail.v2alpha.Product], which will become the final + // component of the [Product.name][google.cloud.retail.v2alpha.Product.name]. + // + // If the caller does not have permission to create the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // This field must be unique among all + // [Product][google.cloud.retail.v2alpha.Product]s with the same + // [parent][google.cloud.retail.v2alpha.CreateProductRequest.parent]. + // Otherwise, an ALREADY_EXISTS error is returned. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string product_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [GetProduct][] method. +message GetProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the requested [Product][google.cloud.retail.v2alpha.Product] does not + // exist, a NOT_FOUND error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for [UpdateProduct][] method. +message UpdateProductRequest { + // Required. The product to update/create. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to update does not + // exist and + // [allow_missing][google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing] + // is not set, a NOT_FOUND error is returned. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Product][google.cloud.retail.v2alpha.Product] to update. The immutable and + // output only fields are NOT supported. If not set, all supported fields (the + // fields that are neither immutable nor output only) are updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, a new [Product][google.cloud.retail.v2alpha.Product] will be + // created. In this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for [DeleteProduct][] method. +message DeleteProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to delete the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to delete does not + // exist, a NOT_FOUND error is returned. + // + // The [Product][google.cloud.retail.v2alpha.Product] to delete can neither be + // a + // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2alpha.Product] member nor a + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] with more than one + // [variants][google.cloud.retail.v2alpha.Product.Type.VARIANT]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // All inventory information for the named + // [Product][google.cloud.retail.v2alpha.Product] will be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] +// method. +message ListProductsRequest { + // Required. The parent branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use + // `default_branch` as the branch ID, to list products under the default + // branch. + // + // If the caller does not have permission to list + // [Product][google.cloud.retail.v2alpha.Product]s under this branch, + // regardless of whether or not this branch exists, a PERMISSION_DENIED error + // is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to + // return. If unspecified, defaults to 100. The maximum allowed value is 1000. + // Values above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT error is returned. + int32 page_size = 2; + + // A page token + // [ListProductsResponse.next_page_token][google.cloud.retail.v2alpha.ListProductsResponse.next_page_token], + // received from a previous + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; + + // A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2alpha.ListProductsRequest.filter] is unset. + // * List + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s sharing the same + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]. For example: + // `primary_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2alpha.Product]s bundled in a + // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2alpha.Product]. + // For example: + // `collection_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2alpha.Product]s with a partibular + // type. For example: + // `type = "PRIMARY"` + // `type = "VARIANT"` + // `type = "COLLECTION"` + // + // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + // + // If the specified + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] or + // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2alpha.Product] does not exist, a NOT_FOUND + // error is returned. + string filter = 4; + + // The fields of [Product][google.cloud.retail.v2alpha.Product] to return in + // the responses. If not set or empty, the following fields are returned: + // + // * [Product.name][google.cloud.retail.v2alpha.Product.name] + // * [Product.id][google.cloud.retail.v2alpha.Product.id] + // * [Product.title][google.cloud.retail.v2alpha.Product.title] + // * [Product.uri][google.cloud.retail.v2alpha.Product.uri] + // * [Product.images][google.cloud.retail.v2alpha.Product.images] + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [Product.brands][google.cloud.retail.v2alpha.Product.brands] + // + // If "*" is provided, all fields are returned. + // [Product.name][google.cloud.retail.v2alpha.Product.name] is always returned + // no matter what mask is set. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask read_mask = 5; + + // If true and + // [page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] is + // empty, + // [ListProductsResponse.total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] + // is set to the total count of matched items irrespective of pagination. + // + // Notice that setting this field to true affects the performance. + bool require_total_size = 6; +} + +// Response message for +// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] +// method. +message ListProductsResponse { + // The [Product][google.cloud.retail.v2alpha.Product]s. + repeated Product products = 1; + + // A token that can be sent as + // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; + + // The total count of matched [Product][google.cloud.retail.v2alpha.Product]s + // irrespective of pagination. The total number of + // [Product][google.cloud.retail.v2alpha.Product]s returned by pagination may + // be less than the + // [total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] + // that matches. + // + // This field is ignored if + // [ListProductsRequest.require_total_size][google.cloud.retail.v2alpha.ListProductsRequest.require_total_size] + // is not set or + // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] + // is not empty. + int32 total_size = 3; +} + +// Request message for [SetInventory][] method. +message SetInventoryRequest { + // Required. The inventory information to update. The allowable fields to + // update are: + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] + // The updated inventory fields must be specified in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask]. + // + // If [SetInventoryRequest.inventory.name][] is empty or invalid, an + // INVALID_ARGUMENT error is returned. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2alpha.Product] named in + // [Product.name][google.cloud.retail.v2alpha.Product.name], regardless of + // whether or not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to update does not + // have existing inventory information, the provided inventory information + // will be inserted. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to update has + // existing inventory information, the provided inventory information will be + // merged while respecting the last update time for each inventory field, + // using the provided or default value for + // [SetInventoryRequest.set_time][google.cloud.retail.v2alpha.SetInventoryRequest.set_time]. + // + // The caller can replace place IDs for a subset of fulfillment types in the + // following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types and corresponding place IDs + // to update in [SetInventoryRequest.inventory.fulfillment_info][] + // + // The caller can clear all place IDs from a subset of fulfillment types in + // the following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types to clear in + // [SetInventoryRequest.inventory.fulfillment_info][] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] + // + // The last update time is recorded for the following inventory fields: + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] + // + // If a full overwrite of inventory information while ignoring timestamps is + // needed, [UpdateProduct][] should be invoked instead. + Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided + // [Product][google.cloud.retail.v2alpha.Product] to update. + // + // At least one field must be provided. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask set_mask = 2; + + // The time when the request is issued, used to prevent + // out-of-order updates on inventory fields with the last update time + // recorded. If not provided, the internal system time will be used. + google.protobuf.Timestamp set_time = 3; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] with + // name [Product.name][google.cloud.retail.v2alpha.Product.name] is not found, + // the inventory update will still be processed and retained for at most 1 day + // until the [Product][google.cloud.retail.v2alpha.Product] is created. If set + // to false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 4; +} + +// Metadata related to the progress of the SetInventory operation. +// Currently empty because there is no meaningful metadata populated from the +// [SetInventory][] method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the [SetInventory][] +// method. +message SetInventoryResponse {} + +// Request message for [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type], such + // as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery" to be added for this + // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type]. + // Duplicate IDs will be automatically ignored. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // If the total number of place IDs exceeds 2000 for this + // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type] after + // adding, then the update will be rejected. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the AddFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesMetadata {} + +// Response of the AddFulfillmentPlacesRequest. Currently empty because +// there is no meaningful response populated from the [AddFulfillmentPlaces][] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for [AddLocalInventories][] method. +message AddLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of inventory information at difference places. Each place + // is identified by its place ID. At most 3000 inventories are allowed per + // request. + repeated LocalInventory local_inventories = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided list of + // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory] to update. The + // field is updated to the provided value. + // + // If a field is set while the place does not have a previous local inventory, + // the local inventory at that store is created. + // + // If a field is set while the value of that field is not provided, the + // original field value, if it exists, is deleted. + // + // If the mask is not set or set with empty paths, all inventory fields will + // be updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask add_mask = 4; + + // The time when the inventory updates are issued. Used to prevent + // out-of-order updates on local inventory fields. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the local inventory will still be processed and retained for at + // most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 6; +} + +// Metadata related to the progress of the AddLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddLocalInventories][] method. +message AddLocalInventoriesMetadata {} + +// Response of the [AddLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [AddLocalInventories][] +// method. +message AddLocalInventoriesResponse {} + +// Request message for [RemoveLocalInventories][] method. +message RemoveLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of place IDs to have their inventory deleted. + // At most 3000 place IDs are allowed per request. + repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; + + // The time when the inventory deletions are issued. Used to prevent + // out-of-order updates and deletions on local inventory fields. If not + // provided, the internal system time will be used. + google.protobuf.Timestamp remove_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the local inventory removal request will still be processed and + // retained for at most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 3; +} + +// Metadata related to the progress of the RemoveLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveLocalInventories][] method. +message RemoveLocalInventoriesMetadata {} + +// Response of the [RemoveLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [RemoveLocalInventories][] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type], + // such as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery", to be removed for this + // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type]. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp remove_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the RemoveFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the [RemoveFulfillmentPlaces][] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto new file mode 100644 index 00000000..879449a4 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto @@ -0,0 +1,40 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "PromotionProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Promotion information. +message Promotion { + // ID of the promotion. For example, "free gift". + // + // The value must be a UTF-8 encoded string with a length limit of 128 + // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, + // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Google Merchant Center property + // [promotion](https://support.google.com/merchants/answer/7050148). + string promotion_id = 1; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto new file mode 100644 index 00000000..6b929f26 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto @@ -0,0 +1,171 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Metadata related to the progress of the Purge operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeMetadata {} + +// Metadata related to the progress of the PurgeProducts operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeProductsMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were deleted successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; +} + +// Request message for PurgeProducts method. +message PurgeProductsRequest { + // Required. The resource name of the branch under which the products are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The filter string to specify the products to be deleted with a + // length limit of 5,000 characters. + // + // Empty string filter is not allowed. "*" implies delete all items in a + // branch. + // + // The eligible fields for filtering are: + // + // * `availability`: Double quoted + // [Product.availability][google.cloud.retail.v2alpha.Product.availability] + // string. + // * `create_time` : in ISO 8601 "zulu" format. + // + // Supported syntax: + // + // * Comparators (">", "<", ">=", "<=", "="). + // Examples: + // * create_time <= "2015-02-13T17:05:46Z" + // * availability = "IN_STOCK" + // + // * Conjunctions ("AND") + // Examples: + // * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" + // + // * Disjunctions ("OR") + // Examples: + // * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" + // + // * Can support nested queries. + // Examples: + // * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") + // OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") + // + // * Filter Limits: + // * Filter should not contain more than 6 conditions. + // * Max nesting depth should not exceed 2 levels. + // + // Examples queries: + // * Delete back order products created before a timestamp. + // create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any products. + bool force = 3; +} + +// Response of the PurgeProductsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeProductsResponse { + // The total count of products purged as a result of the operation. + int64 purge_count = 1; + + // A sample of the product names that will be deleted. + // Only populated if `force` is set to false. A max of 100 names will be + // returned and the names are chosen at random. + repeated string purge_sample = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for PurgeUserEvents method. +message PurgeUserEventsRequest { + // Required. The resource name of the catalog under which the events are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The filter string to specify the events to be deleted with a + // length limit of 5,000 characters. Empty string filter is not allowed. The + // eligible fields for filtering are: + // + // * `eventType`: Double quoted + // [UserEvent.event_type][google.cloud.retail.v2alpha.UserEvent.event_type] + // string. + // * `eventTime`: in ISO 8601 "zulu" format. + // * `visitorId`: Double quoted string. Specifying this will delete all + // events associated with a visitor. + // * `userId`: Double quoted string. Specifying this will delete all events + // associated with a user. + // + // Examples: + // + // * Deleting all events in a time range: + // `eventTime > "2012-04-23T18:25:43.511Z" + // eventTime < "2012-04-23T18:30:43.511Z"` + // * Deleting specific eventType in time range: + // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + // * Deleting all events for a specific visitor: + // `visitorId = "visitor1024"` + // + // The filtering fields are assumed to have an implicit AND. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any user events. + bool force = 3; +} + +// Response of the PurgeUserEventsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeUserEventsResponse { + // The total count of events purged as a result of the operation. + int64 purged_events_count = 1; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto new file mode 100644 index 00000000..f9612734 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto @@ -0,0 +1,832 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service SearchService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" + body: "*" + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] +// method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Product][google.cloud.retail.v2alpha.Product] object, over which the + // facet values are computed. Facet key is case-sensitive. + // + // Allowed facet keys when + // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] + // is not specified: + // + // * textual_field = + // * "brands" + // * "categories" + // * "genders" + // * "ageGroups" + // * "availability" + // * "colorFamilies" + // * "colors" + // * "sizes" + // * "materials" + // * "patterns" + // * "conditions" + // * "attributes.key" + // * "pickupInStore" + // * "shipToStore" + // * "sameDayDelivery" + // * "nextDayDelivery" + // * "customFulfillment1" + // * "customFulfillment2" + // * "customFulfillment3" + // * "customFulfillment4" + // * "customFulfillment5" + // * "inventory(place_id,attributes.key)" + // + // * numerical_field = + // * "price" + // * "discount" + // * "rating" + // * "ratingCount" + // * "attributes.key" + // * "inventory(place_id,price)" + // * "inventory(place_id,original_price)" + // * "inventory(place_id,attributes.key)" + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. For example, when using + // "pickupInStore" as key and set restricted values to + // ["store123", "store456"], only facets for "store123" and "store456" are + // returned. Only supported on textual fields and fulfillments. + // Maximum is 20. + // + // Must be set for the fulfillment facet keys: + // + // * pickupInStore + // + // * shipToStore + // + // * sameDayDelivery + // + // * nextDayDelivery + // + // * customFulfillment1 + // + // * customFulfillment2 + // + // * customFulfillment3 + // + // * customFulfillment4 + // + // * customFulfillment5 + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the + // "categories" facet will give only "Women > Shoe" and "Women > Dress". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 8; + + // Only get facet values that contains the given strings. For example, + // suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the + // "categories" facet will give only "Women > Shoe" and "Men > Shoe". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 9; + + // The order in which [Facet.values][] are returned. + // + // Allowed values are: + // + // * "count desc", which means order by [Facet.FacetValue.count][] + // descending. + // + // * "value desc", which means order by [Facet.FacetValue.value][] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.intervals]; + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // are sorted in the order given by + // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.restricted_values]. + string order_by = 4; + + // The query that is used to compute facet for the given facet key. + // When provided, it will override the default behavior of facet + // computation. The query syntax is the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for detail syntax and limitations. Notice that there is no limitation + // on + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // when query is specified. + // + // In the response, [FacetValue.value][] will be always "1" and + // [FacetValue.count][] will be the number of results that matches the + // query. + // + // For example, you can set a customized facet for "shipToStore", + // where + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // is "customizedShipToStore", and + // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] + // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". + // Then the facet will count the products that are both in stock and ship + // to store "123". + string query = 5; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // By default, + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // For example, suppose there are 100 products with color facet "Red" and + // 200 products with color facet "Blue". A query containing the filter + // "colorFamilies:ANY("Red")" and have "colorFamilies" as + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // will by default return the "Red" with count 100. + // + // If this field contains "colorFamilies", then the query returns both the + // "Red" with count 100 and "Blue" with count 200, because the + // "colorFamilies" key is now excluded from the filter. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined by Google + // Retail Search. It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined by + // Google Retail Search. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how Google Retail Search orders "gender" and + // "rating" facets. However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // The specifications of dynamically generated facets. + message DynamicFacetSpec { + // Enum to control DynamicFacet mode + enum Mode { + // Default value. + MODE_UNSPECIFIED = 0; + + // Disable Dynamic Facet. + DISABLED = 1; + + // Automatic mode built by Google Retail Search. + ENABLED = 2; + } + + // Mode of the DynamicFacet feature. + // Defaults to + // [Mode.DISABLED][google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode.DISABLED] + // if it's unset. + Mode mode = 1; + } + + // Boost specification to boost certain items. + message BoostSpec { + // Boost applies to products which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue": + // * (id: ANY("product_1", "product_2")) AND (colorFamilies: + // ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a product matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 10. + repeated ConditionBoostSpec condition_boost_specs = 1; + + // Whether to skip boostspec validation. If this field is set to true, + // invalid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // will be ignored and valid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // will still be applied. + optional bool skip_boost_spec_validation = 2; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. This defaults to + // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by Google Retail Search. + AUTO = 3; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + + // Whether to pin unexpanded results. If this field is set to true, + // unexpanded products are always at the top of the search results, followed + // by the expanded results. + bool pin_unexpanded_results = 2; + } + + // The specification for personalization. + message PersonalizationSpec { + // The personalization mode of each search request. + enum Mode { + // Default value. Defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The relevance threshold of the search results. The higher relevance + // threshold is, the higher relevant results are shown and the less number of + // results are returned. + enum RelevanceThreshold { + // Default value. Defaults to + // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH]. + RELEVANCE_THRESHOLD_UNSPECIFIED = 0; + + // High relevance threshold. + HIGH = 1; + + // Medium relevance threshold. + MEDIUM = 2; + + // Low relevance threshold. + LOW = 3; + + // Lowest relevance threshold. + LOWEST = 4; + } + + // The search mode of each search request. + enum SearchMode { + // Default value. In this case both product search and faceted search will + // be performed. Both [SearchResponse.SearchResult] and + // [SearchResponse.Facet] will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only [SearchResponse.SearchResult] will be returned. + // [SearchResponse.Facet] will not be returned, even if + // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] + // or + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] + // is set. + PRODUCT_SEARCH_ONLY = 1; + + // Only faceted search will be performed. The product search will be + // disabled. + // + // When in this mode, one or both of [SearchRequest.facet_spec][] and + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] + // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only + // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the search engine placement, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` + // This field is used to identify the serving configuration name and the set + // of models that will be used to make the search. + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. + // + // Use "default_branch" as the branch ID or leave this field empty, to search + // products under the default branch. + string branch = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Raw search query. + string query = 3; + + // Required. A unique identifier for tracking visitors. For example, this + // could be implemented with an HTTP cookie, which should be able to uniquely + // identify a visitor on a single device. This unique identifier should not + // change if the visitor logs in or out of the website. + // + // This should be the same identifier as + // [UserEvent.visitor_id][google.cloud.retail.v2alpha.UserEvent.visitor_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; + + // User information. + UserInfo user_info = 5; + + // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to + // return. If unspecified, defaults to a reasonable value. The maximum allowed + // value is 120. Values above 120 will be coerced to 120. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 7; + + // A page token + // [SearchResponse.next_page_token][google.cloud.retail.v2alpha.SearchResponse.next_page_token], + // received from a previous + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 8; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the + // [Product][google.cloud.retail.v2alpha.Product]s deemed by the API as + // relevant) in search results. This field is only considered if + // [page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] is + // unset. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 offset = 9; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. Filter + // expression is case-sensitive. See more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string filter = 10; + + // The default filter that is applied when a user performs a search without + // checking any filters on the search page. + // + // The filter applied to every search request when quality improvement such as + // query expansion is needed. For example, if a query does not have enough + // results, an expanded query with + // [SearchRequest.canonical_filter][google.cloud.retail.v2alpha.SearchRequest.canonical_filter] + // will be returned as a supplement of the original query. This field is + // strongly recommended to achieve high search quality. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for more details about filter syntax. + string canonical_filter = 28; + + // The order in which products are returned. Products can be ordered by + // a field in an [Product][google.cloud.retail.v2alpha.Product] object. Leave + // it unset if ordered by relevance. OrderBy expression is case-sensitive. See + // more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#order). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string order_by = 11; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated FacetSpec facet_specs = 12; + + // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + // to enable dynamic facets. Do not set this field. + // + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; + + // Boost specification to boost certain products. See more details at this + // [user guide](https://cloud.google.com/retail/docs/boosting). + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] + // and [SearchRequest.boost_spec] are set, the boost conditions from both + // places are evaluated. If a search request matches multiple boost + // conditions, the final boost score is equal to the sum of the boost scores + // from all matched boost conditions. + BoostSpec boost_spec = 13; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + QueryExpansionSpec query_expansion_spec = 14; + + // The relevance threshold of the search results. + // + // Defaults to + // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH], + // which means only the most relevant results are shown, and the least number + // of results are returned. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + RelevanceThreshold relevance_threshold = 15; + + // The keys to fetch and rollup the matching + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s attributes, + // [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo] or + // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s attributes. + // The attributes from all the matching + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s or + // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s are merged + // and de-duplicated. Notice that rollup attributes will lead to extra query + // latency. Maximum number of keys is 30. + // + // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], a + // fulfillment type and a fulfillment ID must be provided in the format of + // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + // "pickupInStore" is fulfillment type and "store123" is the store ID. + // + // Supported keys are: + // + // * colorFamilies + // * price + // * originalPrice + // * discount + // * variantId + // * inventory(place_id,price) + // * inventory(place_id,original_price) + // * inventory(place_id,attributes.key), where key is any key in the + // [Product.inventories.attributes][] map. + // * attributes.key, where key is any key in the + // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes] map. + // * pickupInStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "pickup-in-store". + // * shipToStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "ship-to-store". + // * sameDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "same-day-delivery". + // * nextDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "next-day-delivery". + // * customFulfillment1.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-1". + // * customFulfillment2.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-2". + // * customFulfillment3.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-3". + // * customFulfillment4.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-4". + // * customFulfillment5.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-5". + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + repeated string variant_rollup_keys = 17; + + // The categories associated with a category page. Required for category + // navigation queries to achieve good search quality. The format should be + // the same as + // [UserEvent.page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories]; + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + repeated string page_categories = 23; + + // The search mode of the search request. If not specified, a single search + // request triggers both product search and faceted search. + SearchMode search_mode = 31; + + // The specification for personalization. + PersonalizationSpec personalization_spec = 32; +} + +// Response message for +// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] +// method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Product.id][google.cloud.retail.v2alpha.Product.id] of the searched + // [Product][google.cloud.retail.v2alpha.Product]. + string id = 1; + + // The product data snippet in the search response. Only + // [Product.name][google.cloud.retail.v2alpha.Product.name] is guaranteed to + // be populated. + // + // [Product.variants][google.cloud.retail.v2alpha.Product.variants] contains + // the product variants that match the search query. If there are multiple + // product variants matching the query, top 5 most relevant product variants + // are returned and ordered by relevancy. + // + // If relevancy can be deternmined, use + // [matching_variant_fields][google.cloud.retail.v2alpha.SearchResponse.SearchResult.matching_variant_fields] + // to look up matched product variants fields. If relevancy cannot be + // determined, e.g. when searching "shoe" all products in a shoe product can + // be a match, 5 product variants are returned but order is meaningless. + Product product = 2; + + // The count of matched + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s. + int32 matching_variant_count = 3; + + // If a [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] matches the search query, + // this map indicates which [Product][google.cloud.retail.v2alpha.Product] + // fields are matched. The key is the + // [Product.name][google.cloud.retail.v2alpha.Product.name], the value is a + // field mask of the matched [Product][google.cloud.retail.v2alpha.Product] + // fields. If matched attributes cannot be determined, this map will be + // empty. + // + // For example, a key "sku1" with field mask + // "products.color_info" indicates there is a match between + // "sku1" [ColorInfo][google.cloud.retail.v2alpha.ColorInfo] and the query. + map matching_variant_fields = 4; + + // The rollup matching + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] attributes. The key is one + // of the + // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2alpha.SearchRequest.variant_rollup_keys]. + // The values are the merged and de-duplicated + // [Product][google.cloud.retail.v2alpha.Product] attributes. Notice that + // the rollup values are respect filter. For example, when filtering by + // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is + // returned. + // + // For textual and numerical attributes, the rollup values is a list of + // string or double values with type + // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if + // there are two variants with colors "red" and "blue", the rollup values + // are + // + // { key: "colorFamilies" + // value { + // list_value { + // values { string_value: "red" } + // values { string_value: "blue" } + // } + // } + // } + // + // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], the + // rollup values is a double value with type + // [google.protobuf.Value][google.protobuf.Value]. For example, + // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there + // are 10 variants in this product are available in the store "store1". + map variant_rollup_values = 5; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colorFamilies". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + } + + // The key for this facet. E.g., "colorFamilies" or "price" or + // "attributes.attr1". + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Information describing query expansion including whether expansion has + // occurred. + message QueryExpansionInfo { + // Bool describing whether query expansion has occurred. + bool expanded_query = 1; + + // Number of pinned results. This field will only be set when expansion + // happens and + // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] + // is set to true. + int64 pinned_result_count = 2; + } + + // A list of matched items. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.retail.v2alpha.SearchResponse.results] + // returned by pagination may be less than the + // [total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] that + // matches. + int32 total_size = 3; + + // If spell correction applies, the corrected query. Otherwise, empty. + string corrected_query = 4; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this + // search, which enables accurate attribution of search model performance. + string attribution_token = 5; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 6; + + // Query expansion information for the returned results. + QueryExpansionInfo query_expansion_info = 7; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search will be performed, and only + // [redirect_uri][google.cloud.retail.v2alpha.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] + // will be set in the response. + string redirect_uri = 10; + + // The fully qualified resource name of applied + // [controls](https://cloud.google.com/retail/docs/serving-control-rules). + repeated string applied_controls = 12; + + // The invalid + // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto new file mode 100644 index 00000000..c339f310 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto @@ -0,0 +1,247 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configures metadata that is used to generate serving time results (e.g. +// search results or recommendation predictions). +// The ServingConfig is passed in the search and predict request and together +// with the Catalog.default_branch, generates results. +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // Immutable. Fully qualified name + // projects/*/locations/global/catalogs/*/servingConfig/* + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable serving config display name. Used in Retail + // UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // The id of the model to use at serving time. + // Currently only RecommendationModels are supported: + // https://cloud.google.com/retail/recommendations-ai/docs/create-models + // Can be changed but only to a compatible model (e.g. + // others-you-may-like CTR to others-you-may-like CVR). + // + // Required when + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string model_id = 3; + + // How much price ranking we want in serving results. + // Price reranking causes product items with a similar + // recommendation probability to be ordered by price, with the + // highest-priced items first. This setting could result in a decrease in + // click-through and conversion rates. + // Allowed values are: + // + // * 'no-price-reranking' + // * 'low-price-raranking' + // * 'medium-price-reranking' + // * 'high-price-reranking' + // + // If not specified, we choose default based on model type. Default value: + // 'no-price-reranking'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string price_reranking_level = 4; + + // Facet specifications for faceted search. If empty, no facets are returned. + // The ids refer to the ids of [Control][google.cloud.retail.v2alpha.Control] + // resources with only the Facet control set. These controls are assumed to be + // in the same [Catalog][google.cloud.retail.v2alpha.Catalog] as the + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]. + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string facet_control_ids = 5; + + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; + + // Condition boost specifications. If a product matches multiple conditions + // in the specifications, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 100. + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] + // and [SearchRequest.boost_spec] are set, the boost conditions from both + // places are evaluated. If a search request matches multiple boost + // conditions, the final boost score is equal to the sum of the boost scores + // from all matched boost conditions. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string boost_control_ids = 7; + + // Condition filter specifications. If a product matches multiple conditions + // in the specifications, filters from these specifications are all + // applied and combined via the AND operator. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string filter_control_ids = 9; + + // Condition redirect specifications. Only the first triggered redirect action + // is applied, even if multiple apply. Maximum number of specifications is + // 1000. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string redirect_control_ids = 10; + + // Condition synonyms specifications. If multiple syonyms conditions match, + // all matching synonyms control in the list will execute. Order of controls + // in the list will not matter. Maximum number of specifications is + // 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string twoway_synonyms_control_ids = 18; + + // Condition oneway synonyms specifications. If multiple oneway synonyms + // conditions match, all matching oneway synonyms controls in the list will + // execute. Order of controls in the list will not matter. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string oneway_synonyms_control_ids = 12; + + // Condition do not associate specifications. If multiple do not associate + // conditions match, all matching do not associate controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string do_not_associate_control_ids = 13; + + // Condition replacement specifications. + // - Applied according to the order in the list. + // - A previously replaced term can not be re-replaced. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string replacement_control_ids = 14; + + // Condition ignore specifications. If multiple ignore + // conditions match, all matching ignore controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string ignore_control_ids = 15; + + // How much diversity to use in recommendation model results e.g. + // 'medium-diversity' or 'high-diversity'. Currently supported values: + // + // * 'no-diversity' + // * 'low-diversity' + // * 'medium-diversity' + // * 'high-diversity' + // * 'auto-diversity' + // + // If not specified, we choose default based on recommendation model + // type. Default value: 'no-diversity'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string diversity_level = 8; + + // Whether to add additional category filters on the 'similar-items' model. + // If not specified, we enable it by default. + // Allowed values are: + // + // * 'no-category-match': No additional filtering of original results from + // the model and the customer's filters. + // * 'relaxed-category-match': Only keep results with categories that match + // at least one item categories in the PredictRequests's context item. + // * If customer also sends filters in the PredictRequest, then the results + // will satisfy both conditions (user given and category match). + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string enable_category_filter_level = 16; + + // Required. Immutable. Specifies the solution types that a serving config can + // be associated with. Currently we support setting only one type of solution. + repeated SolutionType solution_types = 19 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto new file mode 100644 index 00000000..48286797 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto @@ -0,0 +1,241 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/serving_config.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for modifying ServingConfig. +service ServingConfigService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a ServingConfig. + // + // A maximum of 100 + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in + // a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a + // FAILED_PRECONDITION error is returned. + rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + body: "serving_config" + }; + option (google.api.method_signature) = + "parent,serving_config,serving_config_id"; + } + + // Deletes a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc DeleteServingConfig(DeleteServingConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a ServingConfig. + rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + patch: "/v2alpha/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + body: "serving_config" + }; + option (google.api.method_signature) = "serving_config,update_mask"; + } + + // Gets a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all ServingConfigs linked to this catalog. + rpc ListServingConfigs(ListServingConfigsRequest) + returns (ListServingConfigsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Enables a Control on the specified ServingConfig. + // The control is added in the last position of the list of controls + // it belongs to (e.g. if it's a facet spec control it will be applied + // in the last position of servingConfig.facetSpecIds) + // Returns a ALREADY_EXISTS error if the control has already been applied. + // Returns a FAILED_PRECONDITION error if the addition could exceed maximum + // number of control allowed for that type of control. + rpc AddControl(AddControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } + + // Disables a Control on the specified ServingConfig. + // The control is removed from the ServingConfig. + // Returns a NOT_FOUND error if the Control is not enabled for the + // ServingConfig. + rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } +} + +// Request for CreateServingConfig method. +message CreateServingConfigRequest { + // Required. Full resource name of parent. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The ServingConfig to create. + ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the ServingConfig, which will become the final + // component of the ServingConfig's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateServingConfig method. +message UpdateServingConfigRequest { + // Required. The ServingConfig to update. + ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to update. The + // following are NOT supported: + // + // * [ServingConfig.name][google.cloud.retail.v2alpha.ServingConfig.name] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteServingConfig method. +message DeleteServingConfigRequest { + // Required. The resource name of the ServingConfig to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for GetServingConfig method. +message GetServingConfigRequest { + // Required. The resource name of the ServingConfig to get. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for ListServingConfigs method. +message ListServingConfigsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 100. If a value greater than 100 is provided, at most 100 results are + // returned. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListServingConfigs` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListServingConfigs method. +message ListServingConfigsResponse { + // All the ServingConfigs for a given catalog. + repeated ServingConfig serving_configs = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request for AddControl method. +message AddControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config - if id is not found a NOT_FOUND error is returned. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for RemoveControl method. +message RemoveControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto new file mode 100644 index 00000000..94f72879 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto @@ -0,0 +1,344 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// UserEvent captures all metadata information Retail API needs to know about +// how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // * `add-to-cart`: Products being added to cart. + // * `category-page-view`: Special pages such as sale or promotion pages + // viewed. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed. + // * `promotion-offered`: Promotion is offered to a user. + // * `promotion-not-offered`: Promotion is not offered to a user. + // * `purchase-complete`: User finishing a purchase. + // * `search`: Product search. + // * `shopping-cart-page-view`: User viewing a shopping cart. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A unique identifier for tracking visitors. + // + // For example, this could be implemented with an HTTP cookie, which should be + // able to uniquely identify a visitor on a single device. This unique + // identifier should not change if the visitor log in/out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analystics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the sesion_id: + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // visitor_id as prefix. + string session_id = 21; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.retail.v2alpha.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups (e.g. using Retail API, using different + // recommendation models). + repeated string experiment_ids = 4; + + // Highly recommended for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be a valid + // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] + // for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. + // The value must be a valid + // [SearchResponse.attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] + // for user events that are the result of + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // This token enables us to accurately attribute page view or purchase back to + // the event and the particular predict response containing this + // clicked/purchased product. If user clicks on product K in the + // recommendation results, pass + // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] + // as a URL parameter to product K's page. When recording events on product + // K's page, log the + // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] + // to this field. + string attribution_token = 5; + + // The main product details related to the event. + // + // This field is required for the following event types: + // + // * `add-to-cart` + // * `detail-page-view` + // * `purchase-complete` + // * `search` + // + // In a `search` event, this field represents the products returned to the end + // user on the current page (the end user may have not finished browsing the + // whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [product_details][google.cloud.retail.v2alpha.UserEvent.product_details] is + // desired. The end user may have not finished browsing the whole page yet. + repeated ProductDetail product_details = 6; + + // The main auto-completion details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionDetail completion_detail = 22; + + // Extra user event features to include in the recommendation model. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Retail API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // traffic_channel, which is how a user arrives at the site. Users can arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 7; + + // The ID or name of the associated shopping cart. This ID is used + // to associate multiple items added or present in the cart before purchase. + // + // This can only be set for `add-to-cart`, `purchase-complete`, or + // `shopping-cart-page-view` events. + string cart_id = 8; + + // A transaction represents the entire purchase transaction. + // + // Required for `purchase-complete` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + PurchaseTransaction purchase_transaction = 9; + + // The user's search query. + // + // See [SearchRequest.query][google.cloud.retail.v2alpha.SearchRequest.query] + // for definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 10; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 16; + + // The order in which products are returned. + // + // See + // [SearchRequest.order_by][google.cloud.retail.v2alpha.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 17; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See + // [SearchRequest.offset][google.cloud.retail.v2alpha.SearchRequest.offset] + // for definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + int32 offset = 18; + + // The categories associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + // + // Required for `category-page-view` events. At least one of + // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string page_categories = 11; + + // User information. + UserInfo user_info = 12; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 13; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string referrer_uri = 14; + + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string page_view_id = 15; +} + +// Detailed product information associated with a user event. +message ProductDetail { + // Required. [Product][google.cloud.retail.v2alpha.Product] information. + // + // Required field(s): + // + // * [Product.id][google.cloud.retail.v2alpha.Product.id] + // + // Optional override field(s): + // + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // + // If any supported optional fields are provided, we will treat them as a full + // override when looking up product information from the catalog. Thus, it is + // important to ensure that the overriding fields are accurate and + // complete. + // + // All other product fields are ignored and instead populated via catalog + // lookup after event ingestion. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Quantity of the product associated with the user event. + // + // For example, this field will be 2 if two products are added to the shopping + // cart for `purchase-complete` event. Required for `add-to-cart` and + // `purchase-complete` event types. + google.protobuf.Int32Value quantity = 2; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionDetail { + // Completion attribution token in + // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2alpha.CompleteQueryResponse.attribution_token]. + string completion_attribution_token = 1; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion]. + string selected_suggestion = 2; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion] + // position, starting from 0. + int32 selected_position = 3; +} + +// A transaction represents the entire purchase transaction. +message PurchaseTransaction { + // The transaction ID with a length limit of 128 characters. + string id = 1; + + // Required. Total non-zero revenue or grand total associated with the + // transaction. This value include shipping, tax, or other adjustments to + // total revenue that you want to include as part of your revenue + // calculations. + float revenue = 2 [(google.api.field_behavior) = REQUIRED]; + + // All the taxes associated with the transaction. + float tax = 3; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = + // [revenue][google.cloud.retail.v2alpha.PurchaseTransaction.revenue] - + // [tax][google.cloud.retail.v2alpha.PurchaseTransaction.tax] - + // [cost][google.cloud.retail.v2alpha.PurchaseTransaction.cost] + float cost = 4; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto new file mode 100644 index 00000000..af97dad9 --- /dev/null +++ b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto @@ -0,0 +1,190 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; +import "google/cloud/retail/v2alpha/purge_config.proto"; +import "google/cloud/retail/v2alpha/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for ingesting end user actions on the customer website. +service UserEventService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" + body: "user_event" + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Retail API JavaScript pixel and Google Tag + // Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }; + } + + // Deletes permanently all user events specified by the filter provided. + // Depending on the number of events specified by the filter, this operation + // could take hours or days to complete. To test a filter, use the list + // command first. + rpc PurgeUserEvents(PurgeUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.PurgeUserEventsResponse" + metadata_type: "google.cloud.retail.v2alpha.PurgeMetadata" + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // Operation.response is of type ImportResponse. Note that it is + // possible for a subset of the items to be successfully inserted. + // Operation.metadata is of type ImportMetadata. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.ImportUserEventsResponse" + metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" + }; + } + + // Starts a user event rejoin operation with latest product catalog. Events + // will not be annotated with detailed product information if product is + // missing from the catalog at the time the user event is ingested, and these + // events are stored as unjoined events with a limited usage on training and + // serving. This method can be used to start a join operation on specified + // events with latest version of product catalog. It can also be used to + // correct events joined with the wrong product catalog. A rejoin operation + // can take hours or days to complete. + rpc RejoinUserEvents(RejoinUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "RejoinUserEventsResponse" + metadata_type: "RejoinUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User event to write. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent catalog name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // The URL including cgi-parameters but excluding the hash fragment with a + // length limit of 5,000 characters. This is often more useful than the + // referer URL, because many browsers only send the domain for 3rd party + // requests. + string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + int64 ets = 4; +} + +// Request message for RejoinUserEvents method. +message RejoinUserEventsRequest { + // The scope of user events to be rejoined with the latest product catalog. + // If the rejoining aims at reducing number of unjoined events, set + // UserEventRejoinScope to UNJOINED_EVENTS. + // If the rejoining aims at correcting product catalog information in joined + // events, set UserEventRejoinScope to JOINED_EVENTS. + // If all events needs to be rejoined, set UserEventRejoinScope to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. + enum UserEventRejoinScope { + // Rejoin all events with the latest product catalog, including both joined + // events and unjoined events. + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; + + // Only rejoin joined events with the latest product catalog. + JOINED_EVENTS = 1; + + // Only rejoin unjoined events with the latest product catalog. + UNJOINED_EVENTS = 2; + } + + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the user event rejoin to define the scope and range of the user + // events to be rejoined with the latest product catalog. Defaults to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + // invalid integer value. + UserEventRejoinScope user_event_rejoin_scope = 2; +} + +// Response message for RejoinUserEvents method. +message RejoinUserEventsResponse { + // Number of user events that were joined with latest product catalog. + int64 rejoined_user_events_count = 1; +} + +// Metadata for RejoinUserEvents method. +message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000..0a46b0bb --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to add. + */ + // const catalogAttribute = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callAddCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.addCatalogAttribute(request); + console.log(response); + } + + callAddCatalogAttribute(); + // [END retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js new file mode 100644 index 00000000..8fe314bf --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_CatalogService_GetAttributesConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetAttributesConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getAttributesConfig(request); + console.log(response); + } + + callGetAttributesConfig(); + // [END retail_v2alpha_generated_CatalogService_GetAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js new file mode 100644 index 00000000..b189f66e --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_CatalogService_GetCompletionConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetCompletionConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getCompletionConfig(request); + console.log(response); + } + + callGetCompletionConfig(); + // [END retail_v2alpha_generated_CatalogService_GetCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js new file mode 100644 index 00000000..075a2b10 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js @@ -0,0 +1,58 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2alpha_generated_CatalogService_GetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.getDefaultBranch(request); + console.log(response); + } + + callGetDefaultBranch(); + // [END retail_v2alpha_generated_CatalogService_GetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js new file mode 100644 index 00000000..2bed2f3f --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_CatalogService_ListCatalogs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The account resource name with an associated location. + * If the caller does not have permission to list + * Catalog google.cloud.retail.v2alpha.Catalog s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Catalog google.cloud.retail.v2alpha.Catalog s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListCatalogsResponse.next_page_token google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token, + * received from a previous + * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callListCatalogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCatalogs(); + // [END retail_v2alpha_generated_CatalogService_ListCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000..81358df9 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, key) { + // [START retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name key of the + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to remove. + */ + // const key = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callRemoveCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + key, + }; + + // Run request + const response = await retailClient.removeCatalogAttribute(request); + console.log(response); + } + + callRemoveCatalogAttribute(); + // [END retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000..2fdfc582 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.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(attributesConfig, catalogAttribute) { + // [START retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The updated + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute. + */ + // const catalogAttribute = {} + /** + * Indicates which fields in the provided + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to update. + * The following are NOT supported: + * * CatalogAttribute.key google.cloud.retail.v2alpha.CatalogAttribute.key + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callReplaceCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.replaceCatalogAttribute(request); + console.log(response); + } + + callReplaceCatalogAttribute(); + // [END retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js new file mode 100644 index 00000000..7fce54ef --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2alpha_generated_CatalogService_SetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * The final component of the resource name of a branch. + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * If there are no sufficient active products in the targeted branch and + * force google.cloud.retail.v2alpha.SetDefaultBranchRequest.force is not + * set, a FAILED_PRECONDITION error is returned. + */ + // const branchId = 'abc123' + /** + * Some note on this request, this can be retrieved by + * CatalogService.GetDefaultBranch google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch + * before next valid default branch set occurs. + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const note = 'abc123' + /** + * If set to true, it permits switching to a branch with + * branch_id google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id + * even if it has no sufficient active products. + */ + // const force = true + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callSetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.setDefaultBranch(request); + console.log(response); + } + + callSetDefaultBranch(); + // [END retail_v2alpha_generated_CatalogService_SetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js new file mode 100644 index 00000000..bf5828a2 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.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(attributesConfig) { + // [START retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The + * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. + */ + // const attributesConfig = {} + /** + * Indicates which fields in the provided + * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. + * The following is the only supported field: + * * AttributesConfig.catalog_attributes google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateAttributesConfig() { + // Construct request + const request = { + attributesConfig, + }; + + // Run request + const response = await retailClient.updateAttributesConfig(request); + console.log(response); + } + + callUpdateAttributesConfig(); + // [END retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js new file mode 100644 index 00000000..81ee698f --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.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(catalog) { + // [START retail_v2alpha_generated_CatalogService_UpdateCatalog_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Catalog google.cloud.retail.v2alpha.Catalog to update. + * If the caller does not have permission to update the + * Catalog google.cloud.retail.v2alpha.Catalog, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the Catalog google.cloud.retail.v2alpha.Catalog to update does not + * exist, a NOT_FOUND error is returned. + */ + // const catalog = {} + /** + * Indicates which fields in the provided + * Catalog google.cloud.retail.v2alpha.Catalog to update. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCatalog() { + // Construct request + const request = { + catalog, + }; + + // Run request + const response = await retailClient.updateCatalog(request); + console.log(response); + } + + callUpdateCatalog(); + // [END retail_v2alpha_generated_CatalogService_UpdateCatalog_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js new file mode 100644 index 00000000..62e6eea3 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(completionConfig) { + // [START retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The + * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. + * If the caller does not have permission to update the + * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig, then a + * PERMISSION_DENIED error is returned. + * If the CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to + * update does not exist, a NOT_FOUND error is returned. + */ + // const completionConfig = {} + /** + * Indicates which fields in the provided + * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. + * The following are the only supported fields: + * * CompletionConfig.matching_order google.cloud.retail.v2alpha.CompletionConfig.matching_order + * * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions + * * CompletionConfig.min_prefix_length google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length + * * CompletionConfig.auto_learning google.cloud.retail.v2alpha.CompletionConfig.auto_learning + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCompletionConfig() { + // Construct request + const request = { + completionConfig, + }; + + // Run request + const response = await retailClient.updateCompletionConfig(request); + console.log(response); + } + + callUpdateCompletionConfig(); + // [END retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js new file mode 100644 index 00000000..6f768b76 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js @@ -0,0 +1,117 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog, query) { + // [START retail_v2alpha_generated_CompletionService_CompleteQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Catalog for which the completion is performed. + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * Required. The query used to generate suggestions. + * The maximum number of allowed characters is 255. + */ + // const query = 'abc123' + /** + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see Tags for + * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + */ + // const languageCodes = 'abc123' + /** + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * Supported formats: + * * `UNKNOWN_DEVICE_TYPE` + * * `DESKTOP` + * * `MOBILE` + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + */ + // const deviceType = 'abc123' + /** + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * CompletionService.ImportCompletionData google.cloud.retail.v2alpha.CompletionService.ImportCompletionData. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * Current supported values: + * * user-data + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + */ + // const dataset = 'abc123' + /** + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions. + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + catalog, + query, + }; + + // Run request + const response = await retailClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END retail_v2alpha_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js new file mode 100644 index 00000000..b54422e5 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.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, inputConfig) { + // [START retail_v2alpha_generated_CompletionService_ImportCompletionData_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog which the suggestions dataset belongs to. + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callImportCompletionData() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importCompletionData(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportCompletionData(); + // [END retail_v2alpha_generated_CompletionService_ImportCompletionData_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js new file mode 100644 index 00000000..bacd422a --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.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, control, controlId) { + // [START retail_v2alpha_generated_ControlService_CreateControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of parent catalog. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Required. The Control to create. + */ + // const control = {} + /** + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callCreateControl() { + // Construct request + const request = { + parent, + control, + controlId, + }; + + // Run request + const response = await retailClient.createControl(request); + console.log(response); + } + + callCreateControl(); + // [END retail_v2alpha_generated_ControlService_CreateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js new file mode 100644 index 00000000..6afa1e03 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ControlService_DeleteControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callDeleteControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteControl(request); + console.log(response); + } + + callDeleteControl(); + // [END retail_v2alpha_generated_ControlService_DeleteControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js new file mode 100644 index 00000000..a0c4c927 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ControlService_GetControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callGetControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getControl(request); + console.log(response); + } + + callGetControl(); + // [END retail_v2alpha_generated_ControlService_GetControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js new file mode 100644 index 00000000..c09815fd --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_ControlService_ListControls_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + /** + * Optional. A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2alpha.ListControlsRequest.filter is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + */ + // const filter = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callListControls() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listControlsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListControls(); + // [END retail_v2alpha_generated_ControlService_ListControls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js new file mode 100644 index 00000000..7f0e4c67 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(control) { + // [START retail_v2alpha_generated_ControlService_UpdateControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Control to update. + */ + // const control = {} + /** + * Indicates which fields in the provided + * Control google.cloud.retail.v2alpha.Control to update. The following are + * NOT supported: + * * Control.name google.cloud.retail.v2alpha.Control.name + * If not set or empty, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callUpdateControl() { + // Construct request + const request = { + control, + }; + + // Run request + const response = await retailClient.updateControl(request); + console.log(response); + } + + callUpdateControl(); + // [END retail_v2alpha_generated_ControlService_UpdateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js new file mode 100644 index 00000000..f49c45f1 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js @@ -0,0 +1,161 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, userEvent) { + // [START retail_v2alpha_generated_PredictionService_Predict_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see Managing + * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + */ + // const placement = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + */ + // const userEvent = {} + /** + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + */ + // const pageSize = 1234 + /** + * The previous PredictResponse.next_page_token. + */ + // const pageToken = 'abc123' + /** + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * Examples: + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + */ + // const filter = 'abc123' + /** + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + */ + // const validateOnly = true + /** + * Additional domain specific parameters for the predictions. + * Allowed values: + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + */ + // const params = 1234 + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + + // Imports the Retail library + const {PredictionServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new PredictionServiceClient(); + + async function callPredict() { + // Construct request + const request = { + placement, + userEvent, + }; + + // Run request + const response = await retailClient.predict(request); + console.log(response); + } + + callPredict(); + // [END retail_v2alpha_generated_PredictionService_Predict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js new file mode 100644 index 00000000..c15b5aa0 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type. + * Duplicate IDs will be automatically ignored. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * If the total number of place IDs exceeds 2000 for this + * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type after + * adding, then the update will be rejected. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddFulfillmentPlaces(); + // [END retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js new file mode 100644 index 00000000..1a0bcb74 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js @@ -0,0 +1,100 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, localInventories) { + // [START retail_v2alpha_generated_ProductService_AddLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + */ + // const localInventories = 1234 + /** + * Indicates which inventory fields in the provided list of + * LocalInventory google.cloud.retail.v2alpha.LocalInventory to update. The + * field is updated to the provided value. + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const addMask = {} + /** + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddLocalInventories() { + // Construct request + const request = { + product, + localInventories, + }; + + // Run request + const [operation] = await retailClient.addLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddLocalInventories(); + // [END retail_v2alpha_generated_ProductService_AddLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js new file mode 100644 index 00000000..d452aae4 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, product, productId) { + // [START retail_v2alpha_generated_ProductService_CreateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + */ + // const parent = 'abc123' + /** + * Required. The Product google.cloud.retail.v2alpha.Product to create. + */ + // const product = {} + /** + * Required. The ID to use for the + * Product google.cloud.retail.v2alpha.Product, which will become the final + * component of the Product.name google.cloud.retail.v2alpha.Product.name. + * If the caller does not have permission to create the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * This field must be unique among all + * Product google.cloud.retail.v2alpha.Product s with the same + * parent google.cloud.retail.v2alpha.CreateProductRequest.parent. + * Otherwise, an ALREADY_EXISTS error is returned. + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const productId = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + productId, + }; + + // Run request + const response = await retailClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END retail_v2alpha_generated_ProductService_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js new file mode 100644 index 00000000..7470b33d --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_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(name) { + // [START retail_v2alpha_generated_ProductService_DeleteProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to delete the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2alpha.Product to delete does not + * exist, a NOT_FOUND error is returned. + * The Product google.cloud.retail.v2alpha.Product to delete can neither be + * a + * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION + * Product google.cloud.retail.v2alpha.Product member nor a + * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY + * Product google.cloud.retail.v2alpha.Product with more than one + * variants google.cloud.retail.v2alpha.Product.Type.VARIANT. Otherwise, an + * INVALID_ARGUMENT error is returned. + * All inventory information for the named + * Product google.cloud.retail.v2alpha.Product will be deleted. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END retail_v2alpha_generated_ProductService_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js new file mode 100644 index 00000000..52340240 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ProductService_GetProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the requested Product google.cloud.retail.v2alpha.Product does not + * exist, a NOT_FOUND error is returned. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END retail_v2alpha_generated_ProductService_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js new file mode 100644 index 00000000..26a70a51 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js @@ -0,0 +1,93 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2alpha_generated_ProductService_ImportProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. + */ + // const errorsConfig = {} + /** + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + */ + // const updateMask = {} + /** + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * Only supported when + * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode + * is set to `FULL`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callImportProducts() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProducts(); + // [END retail_v2alpha_generated_ProductService_ImportProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js new file mode 100644 index 00000000..a9e1ed2f --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js @@ -0,0 +1,141 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_ProductService_ListProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * If the caller does not have permission to list + * Product google.cloud.retail.v2alpha.Product s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Product google.cloud.retail.v2alpha.Product s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT error is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListProductsResponse.next_page_token google.cloud.retail.v2alpha.ListProductsResponse.next_page_token, + * received from a previous + * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2alpha.ListProductsRequest.filter is unset. + * * List + * Product.Type.VARIANT google.cloud.retail.v2alpha.Product.Type.VARIANT + * Product google.cloud.retail.v2alpha.Product s sharing the same + * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY + * Product google.cloud.retail.v2alpha.Product. For example: + * `primary_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2alpha.Product s bundled in a + * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION + * Product google.cloud.retail.v2alpha.Product. + * For example: + * `collection_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2alpha.Product s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * If the specified + * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY + * Product google.cloud.retail.v2alpha.Product or + * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION + * Product google.cloud.retail.v2alpha.Product does not exist, a NOT_FOUND + * error is returned. + */ + // const filter = 'abc123' + /** + * The fields of Product google.cloud.retail.v2alpha.Product to return in + * the responses. If not set or empty, the following fields are returned: + * * Product.name google.cloud.retail.v2alpha.Product.name + * * Product.id google.cloud.retail.v2alpha.Product.id + * * Product.title google.cloud.retail.v2alpha.Product.title + * * Product.uri google.cloud.retail.v2alpha.Product.uri + * * Product.images google.cloud.retail.v2alpha.Product.images + * * Product.price_info google.cloud.retail.v2alpha.Product.price_info + * * Product.brands google.cloud.retail.v2alpha.Product.brands + * If "*" is provided, all fields are returned. + * Product.name google.cloud.retail.v2alpha.Product.name is always returned + * no matter what mask is set. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const readMask = {} + /** + * If true and + * page_token google.cloud.retail.v2alpha.ListProductsRequest.page_token is + * empty, + * ListProductsResponse.total_size google.cloud.retail.v2alpha.ListProductsResponse.total_size + * is set to the total count of matched items irrespective of pagination. + * Notice that setting this field to true affects the performance. + */ + // const requireTotalSize = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END retail_v2alpha_generated_ProductService_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js new file mode 100644 index 00000000..55d09aef --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js @@ -0,0 +1,101 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2alpha_generated_ProductService_PurgeProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the branch under which the products are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the products to be deleted with a + * length limit of 5,000 characters. + * Empty string filter is not allowed. "*" implies delete all items in a + * branch. + * The eligible fields for filtering are: + * * `availability`: Double quoted + * Product.availability google.cloud.retail.v2alpha.Product.availability + * string. + * * `create_time` : in ISO 8601 "zulu" format. + * Supported syntax: + * * Comparators (">", "<", ">=", "<=", "="). + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" + * * availability = "IN_STOCK" + * * Conjunctions ("AND") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" + * * Disjunctions ("OR") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" + * * Can support nested queries. + * Examples: + * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") + * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") + * * Filter Limits: + * * Filter should not contain more than 6 conditions. + * * Max nesting depth should not exceed 2 levels. + * Examples queries: + * * Delete back order products created before a timestamp. + * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any products. + */ + // const force = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END retail_v2alpha_generated_ProductService_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000..9543acde --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js @@ -0,0 +1,111 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveFulfillmentPlaces(); + // [END retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js new file mode 100644 index 00000000..903fe738 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, placeIds) { + // [START retail_v2alpha_generated_ProductService_RemoveLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + */ + // const placeIds = 'abc123' + /** + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveLocalInventories() { + // Construct request + const request = { + product, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveLocalInventories(); + // [END retail_v2alpha_generated_ProductService_RemoveLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js new file mode 100644 index 00000000..00d04376 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js @@ -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 +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inventory) { + // [START retail_v2alpha_generated_ProductService_SetInventory_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The inventory information to update. The allowable fields to + * update are: + * * Product.price_info google.cloud.retail.v2alpha.Product.price_info + * * Product.availability google.cloud.retail.v2alpha.Product.availability + * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info + * The updated inventory fields must be specified in + * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask. + * If SetInventoryRequest.inventory.name is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2alpha.Product named in + * Product.name google.cloud.retail.v2alpha.Product.name, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2alpha.Product to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * If the Product google.cloud.retail.v2alpha.Product to update has + * existing inventory information, the provided inventory information will be + * merged while respecting the last update time for each inventory field, + * using the provided or default value for + * SetInventoryRequest.set_time google.cloud.retail.v2alpha.SetInventoryRequest.set_time. + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in SetInventoryRequest.inventory.fulfillment_info + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types to clear in + * SetInventoryRequest.inventory.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids + * The last update time is recorded for the following inventory fields: + * * Product.price_info google.cloud.retail.v2alpha.Product.price_info + * * Product.availability google.cloud.retail.v2alpha.Product.availability + * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info + * If a full overwrite of inventory information while ignoring timestamps is + * needed, UpdateProduct should be invoked instead. + */ + // const inventory = {} + /** + * Indicates which inventory fields in the provided + * Product google.cloud.retail.v2alpha.Product to update. + * At least one field must be provided. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const setMask = {} + /** + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + */ + // const setTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product with + * name Product.name google.cloud.retail.v2alpha.Product.name is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the Product google.cloud.retail.v2alpha.Product is created. If set + * to false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callSetInventory() { + // Construct request + const request = { + inventory, + }; + + // Run request + const [operation] = await retailClient.setInventory(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInventory(); + // [END retail_v2alpha_generated_ProductService_SetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js new file mode 100644 index 00000000..db9b00e4 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START retail_v2alpha_generated_ProductService_UpdateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The product to update/create. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2alpha.Product to update does not + * exist and + * allow_missing google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing + * is not set, a NOT_FOUND error is returned. + */ + // const product = {} + /** + * Indicates which fields in the provided + * Product google.cloud.retail.v2alpha.Product to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, a new Product google.cloud.retail.v2alpha.Product will be + * created. In this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await retailClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END retail_v2alpha_generated_ProductService_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js new file mode 100644 index 00000000..9c4c8b0d --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js @@ -0,0 +1,281 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, visitorId) { + // [START retail_v2alpha_generated_SearchService_Search_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + */ + // const placement = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + */ + // const query = 'abc123' + /** + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * This should be the same identifier as + * UserEvent.visitor_id google.cloud.retail.v2alpha.UserEvent.visitor_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * User information. + */ + // const userInfo = {} + /** + * Maximum number of Product google.cloud.retail.v2alpha.Product s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * SearchResponse.next_page_token google.cloud.retail.v2alpha.SearchResponse.next_page_token, + * received from a previous + * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * Product google.cloud.retail.v2alpha.Product s deemed by the API as + * relevant) in search results. This field is only considered if + * page_token google.cloud.retail.v2alpha.SearchRequest.page_token is + * unset. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const filter = 'abc123' + /** + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * SearchRequest.canonical_filter google.cloud.retail.v2alpha.SearchRequest.canonical_filter + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * See + * SearchRequest.filter google.cloud.retail.v2alpha.SearchRequest.filter + * for more details about filter syntax. + */ + // const canonicalFilter = 'abc123' + /** + * The order in which products are returned. Products can be ordered by + * a field in an Product google.cloud.retail.v2alpha.Product object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#order). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const orderBy = 'abc123' + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain products. See more details at this + * user guide (https://cloud.google.com/retail/docs/boosting). + * Notice that if both + * ServingConfig.boost_control_ids google.cloud.retail.v2alpha.ServingConfig.boost_control_ids + * and SearchRequest.boost_spec are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + */ + // const boostSpec = {} + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). + */ + // const queryExpansionSpec = {} + /** + * The relevance threshold of the search results. + * Defaults to + * RelevanceThreshold.HIGH google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + */ + // const relevanceThreshold = {} + /** + * The keys to fetch and rollup the matching + * variant google.cloud.retail.v2alpha.Product.Type.VARIANT + * Product google.cloud.retail.v2alpha.Product s attributes, + * FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo or + * LocalInventory google.cloud.retail.v2alpha.LocalInventory s attributes. + * The attributes from all the matching + * variant google.cloud.retail.v2alpha.Product.Type.VARIANT + * Product google.cloud.retail.v2alpha.Product s or + * LocalInventory google.cloud.retail.v2alpha.LocalInventory s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * For FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * Supported keys are: + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * Product.inventories.attributes map. + * * attributes.key, where key is any key in the + * Product.attributes google.cloud.retail.v2alpha.Product.attributes map. + * * pickupInStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "pickup-in-store". + * * shipToStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-1". + * * customFulfillment2.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-2". + * * customFulfillment3.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-3". + * * customFulfillment4.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-4". + * * customFulfillment5.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-5". + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + */ + // const variantRollupKeys = 'abc123' + /** + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * UserEvent.page_categories google.cloud.retail.v2alpha.UserEvent.page_categories; + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : "Sales > 2017 Black Friday Deals". + */ + // const pageCategories = 'abc123' + /** + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + */ + // const searchMode = {} + /** + * The specification for personalization. + */ + // const personalizationSpec = {} + + // Imports the Retail library + const {SearchServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + placement, + visitorId, + }; + + // Run request + const iterable = await retailClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END retail_v2alpha_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js new file mode 100644 index 00000000..5145a2cb --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2alpha_generated_ServingConfigService_AddControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callAddControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.addControl(request); + console.log(response); + } + + callAddControl(); + // [END retail_v2alpha_generated_ServingConfigService_AddControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js new file mode 100644 index 00000000..5a4982b7 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.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, servingConfig, servingConfigId) { + // [START retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of parent. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Required. The ServingConfig to create. + */ + // const servingConfig = {} + /** + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const servingConfigId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callCreateServingConfig() { + // Construct request + const request = { + parent, + servingConfig, + servingConfigId, + }; + + // Run request + const response = await retailClient.createServingConfig(request); + console.log(response); + } + + callCreateServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000..4ca230b4 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callDeleteServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteServingConfig(request); + console.log(response); + } + + callDeleteServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js new file mode 100644 index 00000000..b88b3af3 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callGetServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getServingConfig(request); + console.log(response); + } + + callGetServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000..b79bfca1 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.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 retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callListServingConfigs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listServingConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServingConfigs(); + // [END retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js new file mode 100644 index 00000000..c1ea7176 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2alpha_generated_ServingConfigService_RemoveControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callRemoveControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.removeControl(request); + console.log(response); + } + + callRemoveControl(); + // [END retail_v2alpha_generated_ServingConfigService_RemoveControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js new file mode 100644 index 00000000..7f236fba --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig) { + // [START retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ServingConfig to update. + */ + // const servingConfig = {} + /** + * Indicates which fields in the provided + * ServingConfig google.cloud.retail.v2alpha.ServingConfig to update. The + * following are NOT supported: + * * ServingConfig.name google.cloud.retail.v2alpha.ServingConfig.name + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callUpdateServingConfig() { + // Construct request + const request = { + servingConfig, + }; + + // Run request + const response = await retailClient.updateServingConfig(request); + console.log(response); + } + + callUpdateServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json b/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json new file mode 100644 index 00000000..1072ee94 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json @@ -0,0 +1,2187 @@ +{ + "clientLibrary": { + "name": "nodejs-retail", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.retail.v2alpha", + "version": "v2alpha" + } + ] + }, + "snippets": [ + { + "regionTag": "retail_v2alpha_generated_CatalogService_ListCatalogs_async", + "title": "CatalogService listCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated with the project.", + "canonical": true, + "file": "catalog_service.list_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListCatalogsResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCatalog_async", + "title": "CatalogService updateCatalog Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s.", + "canonical": true, + "file": "catalog_service.update_catalog.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": ".google.cloud.retail.v2alpha.Catalog" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Catalog", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_SetDefaultBranch_async", + "title": "CatalogService setDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", + "canonical": true, + "file": "catalog_service.set_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "branch_id", + "type": "TYPE_STRING" + }, + { + "name": "note", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_GetDefaultBranch_async", + "title": "CatalogService getDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] method under a specified parent catalog.", + "canonical": true, + "file": "catalog_service.get_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.GetDefaultBranchResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_GetCompletionConfig_async", + "title": "CatalogService getCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig].", + "canonical": true, + "file": "catalog_service.get_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async", + "title": "CatalogService updateCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s.", + "canonical": true, + "file": "catalog_service.update_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", + "async": true, + "parameters": [ + { + "name": "completion_config", + "type": ".google.cloud.retail.v2alpha.CompletionConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_GetAttributesConfig_async", + "title": "CatalogService getAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig].", + "canonical": true, + "file": "catalog_service.get_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async", + "title": "CatalogService updateAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", + "canonical": true, + "file": "catalog_service.update_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": ".google.cloud.retail.v2alpha.AttributesConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async", + "title": "CatalogService addCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "catalog_service.add_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2alpha.CatalogAttribute" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async", + "title": "CatalogService removeCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.remove_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "key", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async", + "title": "CatalogService replaceCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.replace_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2alpha.CatalogAttribute" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CompletionService_CompleteQuery_async", + "title": "CatalogService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 109, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "language_codes", + "type": "TYPE_STRING[]" + }, + { + "name": "device_type", + "type": "TYPE_STRING" + }, + { + "name": "dataset", + "type": "TYPE_STRING" + }, + { + "name": "max_suggestions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.retail.v2alpha.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2alpha.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CompletionService_ImportCompletionData_async", + "title": "CatalogService importCompletionData Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.import_completion_data.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2alpha.CompletionDataInputConfig" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" + }, + "method": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2alpha.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_CreateControl_async", + "title": "CatalogService createControl Sample", + "origin": "API_DEFINITION", + "description": " Creates a Control. If the [Control][google.cloud.retail.v2alpha.Control] to create already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "control_service.create_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "control", + "type": ".google.cloud.retail.v2alpha.Control" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_DeleteControl_async", + "title": "CatalogService deleteControl Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Control. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.delete_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_UpdateControl_async", + "title": "CatalogService updateControl Sample", + "origin": "API_DEFINITION", + "description": " Updates a Control. [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", + "async": true, + "parameters": [ + { + "name": "control", + "type": ".google.cloud.retail.v2alpha.Control" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_GetControl_async", + "title": "CatalogService getControl Sample", + "origin": "API_DEFINITION", + "description": " Gets a Control.", + "canonical": true, + "file": "control_service.get_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_ListControls_async", + "title": "CatalogService listControls Sample", + "origin": "API_DEFINITION", + "description": " Lists all Controls linked to this catalog.", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListControlsResponse", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_PredictionService_Predict_async", + "title": "CatalogService predict Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation prediction.", + "canonical": true, + "file": "prediction_service.predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 153, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2alpha.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.retail.v2alpha.PredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.retail.v2alpha.PredictionServiceClient" + }, + "method": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.retail.v2alpha.PredictionService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_CreateProduct_async", + "title": "CatalogService createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.retail.v2alpha.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_GetProduct_async", + "title": "CatalogService getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_ListProducts_async", + "title": "CatalogService listProducts Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Product][google.cloud.retail.v2alpha.Product]s.", + "canonical": true, + "file": "product_service.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 133, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "read_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "require_total_size", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListProductsResponse", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_UpdateProduct_async", + "title": "CatalogService updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.retail.v2alpha.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_DeleteProduct_async", + "title": "CatalogService deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_PurgeProducts_async", + "title": "CatalogService purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes all selected [Product][google.cloud.retail.v2alpha.Product]s under a branch. This process is asynchronous. If the request is valid, the removal will be enqueued and processed offline. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. Before the operation completes, some [Product][google.cloud.retail.v2alpha.Product]s may still be returned by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. To get a sample of [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] to false.", + "canonical": true, + "file": "product_service.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_ImportProducts_async", + "title": "CatalogService importProducts Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated.", + "canonical": true, + "file": "product_service.import_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2alpha.ProductInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_SetInventory_async", + "title": "CatalogService setInventory Sample", + "origin": "API_DEFINITION", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2alpha.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 116, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", + "async": true, + "parameters": [ + { + "name": "inventory", + "type": ".google.cloud.retail.v2alpha.Product" + }, + { + "name": "set_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "set_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async", + "title": "CatalogService addFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async", + "title": "CatalogService removeFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 103, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_AddLocalInventories_async", + "title": "CatalogService addLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Updates local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 92, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "local_inventories", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "add_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_RemoveLocalInventories_async", + "title": "CatalogService removeLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Remove local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_SearchService_Search_async", + "title": "CatalogService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 273, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2alpha.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.retail.v2alpha.UserInfo" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "canonical_filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "dynamic_facet_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec" + }, + { + "name": "boost_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.BoostSpec" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec" + }, + { + "name": "relevance_threshold", + "type": ".google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold" + }, + { + "name": "variant_rollup_keys", + "type": "TYPE_STRING[]" + }, + { + "name": "page_categories", + "type": "TYPE_STRING[]" + }, + { + "name": "search_mode", + "type": ".google.cloud.retail.v2alpha.SearchRequest.SearchMode" + }, + { + "name": "personalization_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec" + } + ], + "resultType": ".google.cloud.retail.v2alpha.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.retail.v2alpha.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2alpha.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.retail.v2alpha.SearchService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async", + "title": "CatalogService createServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a FAILED_PRECONDITION error is returned.", + "canonical": true, + "file": "serving_config_service.create_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "serving_config", + "type": ".google.cloud.retail.v2alpha.ServingConfig" + }, + { + "name": "serving_config_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async", + "title": "CatalogService deleteServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.delete_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async", + "title": "CatalogService updateServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates a ServingConfig.", + "canonical": true, + "file": "serving_config_service.update_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": ".google.cloud.retail.v2alpha.ServingConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_GetServingConfig_async", + "title": "CatalogService getServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.get_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async", + "title": "CatalogService listServingConfigs Sample", + "origin": "API_DEFINITION", + "description": " Lists all ServingConfigs linked to this catalog.", + "canonical": true, + "file": "serving_config_service.list_serving_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListServingConfigsResponse", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_AddControl_async", + "title": "CatalogService addControl Sample", + "origin": "API_DEFINITION", + "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", + "canonical": true, + "file": "serving_config_service.add_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_RemoveControl_async", + "title": "CatalogService removeControl Sample", + "origin": "API_DEFINITION", + "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", + "canonical": true, + "file": "serving_config_service.remove_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_WriteUserEvent_async", + "title": "CatalogService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2alpha.UserEvent" + } + ], + "resultType": ".google.cloud.retail.v2alpha.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_CollectUserEvent_async", + "title": "CatalogService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_PurgeUserEvents_async", + "title": "CatalogService purgeUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", + "canonical": true, + "file": "user_event_service.purge_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 83, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_ImportUserEvents_async", + "title": "CatalogService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2alpha.UserEventInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_RejoinUserEvents_async", + "title": "CatalogService rejoinUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", + "canonical": true, + "file": "user_event_service.rejoin_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event_rejoin_scope", + "type": ".google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js new file mode 100644 index 00000000..2c259bbf --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2alpha_generated_UserEventService_CollectUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + */ + // const userEvent = 'abc123' + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + */ + // const uri = 'abc123' + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + */ + // const ets = 1234 + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END retail_v2alpha_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js new file mode 100644 index 00000000..733e1b2f --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2alpha_generated_UserEventService_ImportUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. `projects/1234/locations/global/catalogs/default_catalog` + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorsConfig = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END retail_v2alpha_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js new file mode 100644 index 00000000..9d1d604c --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js @@ -0,0 +1,91 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * * `eventType`: Double quoted + * UserEvent.event_type google.cloud.retail.v2alpha.UserEvent.event_type + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * Examples: + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * The filtering fields are assumed to have an implicit AND. + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + */ + // const force = true + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callPurgeUserEvents() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeUserEvents(); + // [END retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000..e72b2378 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + */ + // const userEventRejoinScope = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callRejoinUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await retailClient.rejoinUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRejoinUserEvents(); + // [END retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js new file mode 100644 index 00000000..8742b980 --- /dev/null +++ b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2alpha_generated_UserEventService_WriteUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END retail_v2alpha_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/src/index.ts b/owl-bot-staging/v2alpha/src/index.ts new file mode 100644 index 00000000..ebdb9c41 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/index.ts @@ -0,0 +1,39 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 v2alpha from './v2alpha'; +const CatalogServiceClient = v2alpha.CatalogServiceClient; +type CatalogServiceClient = v2alpha.CatalogServiceClient; +const CompletionServiceClient = v2alpha.CompletionServiceClient; +type CompletionServiceClient = v2alpha.CompletionServiceClient; +const ControlServiceClient = v2alpha.ControlServiceClient; +type ControlServiceClient = v2alpha.ControlServiceClient; +const PredictionServiceClient = v2alpha.PredictionServiceClient; +type PredictionServiceClient = v2alpha.PredictionServiceClient; +const ProductServiceClient = v2alpha.ProductServiceClient; +type ProductServiceClient = v2alpha.ProductServiceClient; +const SearchServiceClient = v2alpha.SearchServiceClient; +type SearchServiceClient = v2alpha.SearchServiceClient; +const ServingConfigServiceClient = v2alpha.ServingConfigServiceClient; +type ServingConfigServiceClient = v2alpha.ServingConfigServiceClient; +const UserEventServiceClient = v2alpha.UserEventServiceClient; +type UserEventServiceClient = v2alpha.UserEventServiceClient; +export {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +export default {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts new file mode 100644 index 00000000..c1af21ae --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts @@ -0,0 +1,1865 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/catalog_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './catalog_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for managing catalog configuration. + * @class + * @memberof v2alpha + */ +export class CatalogServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + catalogServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CatalogServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CatalogServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listCatalogs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.CatalogService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.catalogServiceStub) { + return this.catalogServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.CatalogService. + this.catalogServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.CatalogService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.CatalogService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const catalogServiceStubMethods = + ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch', 'getCompletionConfig', 'updateCompletionConfig', 'getAttributesConfig', 'updateAttributesConfig', 'addCatalogAttribute', 'removeCatalogAttribute', 'replaceCatalogAttribute']; + for (const methodName of catalogServiceStubMethods) { + const callPromise = this.catalogServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.catalogServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Updates the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Catalog} request.catalog + * Required. The {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update does not + * exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.update_catalog.js + * region_tag:retail_v2alpha_generated_CatalogService_UpdateCatalog_async + */ + updateCatalog( + request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|undefined, {}|undefined + ]>; + updateCatalog( + request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog.name': request.catalog!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCatalog(request, options, callback); + } +/** + * Set a specified branch id as default branch. API methods such as + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search}, + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct}, + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as + * default, setting + * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` + * as {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} + * to route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.branchId + * The final component of the resource name of a branch. + * + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * + * If there are no sufficient active products in the targeted branch and + * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.force|force} is not + * set, a FAILED_PRECONDITION error is returned. + * @param {string} request.note + * Some note on this request, this can be retrieved by + * {@link google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} + * before next valid default branch set occurs. + * + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {boolean} request.force + * If set to true, it permits switching to a branch with + * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id|branch_id} + * even if it has no sufficient active products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.set_default_branch.js + * region_tag:retail_v2alpha_generated_CatalogService_SetDefaultBranch_async + */ + setDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|undefined, {}|undefined + ]>; + setDefaultBranch( + request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultBranch(request, options, callback); + } +/** + * Get which branch is currently default branch set by + * {@link google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} + * method under a specified parent catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2alpha.GetDefaultBranchResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.get_default_branch.js + * region_tag:retail_v2alpha_generated_CatalogService_GetDefaultBranch_async + */ + getDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|undefined, {}|undefined + ]>; + getDefaultBranch( + request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.get_completion_config.js + * region_tag:retail_v2alpha_generated_CatalogService_GetCompletionConfig_async + */ + getCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|undefined, {}|undefined + ]>; + getCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getCompletionConfig(request, options, callback); + } +/** + * Updates the + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.CompletionConfig} request.completionConfig + * Required. The + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to + * update does not exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. + * The following are the only supported fields: + * + * * {@link google.cloud.retail.v2alpha.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link google.cloud.retail.v2alpha.CompletionConfig.auto_learning|CompletionConfig.auto_learning} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.update_completion_config.js + * region_tag:retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async + */ + updateCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|undefined, {}|undefined + ]>; + updateCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'completion_config.name': request.completionConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCompletionConfig(request, options, callback); + } +/** + * Gets an {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.get_attributes_config.js + * region_tag:retail_v2alpha_generated_CatalogService_GetAttributesConfig_async + */ + getAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|undefined, {}|undefined + ]>; + getAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getAttributesConfig(request, options, callback); + } +/** + * Updates the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * The catalog attributes in the request will be updated in the catalog, or + * inserted if they do not exist. Existing catalog attributes not included in + * the request will remain unchanged. Attributes that are assigned to + * products, but do not exist at the catalog level, are always included in the + * response. The product attribute is assigned default values for missing + * catalog attribute fields, e.g., searchable and dynamic facetable options. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.AttributesConfig} request.attributesConfig + * Required. The + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. + * The following is the only supported field: + * + * * {@link google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.update_attributes_config.js + * region_tag:retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async + */ + updateAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|undefined, {}|undefined + ]>; + updateAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config.name': request.attributesConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateAttributesConfig(request, options, callback); + } +/** + * Adds the specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to + * add already exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute + * Required. The + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to add. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.add_catalog_attribute.js + * region_tag:retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async + */ + addCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|undefined, {}|undefined + ]>; + addCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.addCatalogAttribute(request, options, callback); + } +/** + * Removes the specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} from the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to + * remove does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {string} request.key + * Required. The attribute name key of the + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to remove. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js + * region_tag:retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async + */ + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|undefined, {}|undefined + ]>; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute(request, options, callback); + } +/** + * Replaces the specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} in the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} by + * updating the catalog attribute with the same + * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to + * replace does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute + * Required. The updated + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to update. + * The following are NOT supported: + * + * * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js + * region_tag:retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async + */ + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|undefined, {}|undefined + ]>; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.replaceCatalogAttribute(request, options, callback); + } + + /** + * Lists all the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s associated + * with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogs( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICatalog[], + protos.google.cloud.retail.v2alpha.IListCatalogsRequest|null, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse + ]>; + listCatalogs( + request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.ICatalog>): void; + listCatalogs( + request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.ICatalog>): void; + listCatalogs( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.ICatalog>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.ICatalog>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICatalog[], + protos.google.cloud.retail.v2alpha.IListCatalogsRequest|null, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listCatalogs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2alpha.Catalog} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogsStream( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.createStream( + this.innerApiCalls.listCatalogs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCatalogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.list_catalogs.js + * region_tag:retail_v2alpha_generated_CatalogService_ListCatalogs_async + */ + listCatalogsAsync( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.asyncIterate( + this.innerApiCalls['listCatalogs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.catalogServiceStub && !this._terminated) { + return this.catalogServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json new file mode 100644 index 00000000..08407daa --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json @@ -0,0 +1,90 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.CatalogService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListCatalogs": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCatalog": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "SetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "AddCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "RemoveCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ReplaceCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts new file mode 100644 index 00000000..36be33c4 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts @@ -0,0 +1,936 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Auto-completion service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2alpha + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importCompletionDataResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportCompletionDataResponse') as gax.protobuf.Type; + const importCompletionDataMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importCompletionData: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importCompletionDataResponse.decode.bind(importCompletionDataResponse), + importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.CompletionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.CompletionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.CompletionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const completionServiceStubMethods = + ['completeQuery', 'importCompletionData']; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Required. Catalog for which the completion is performed. + * + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string} request.visitorId + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {string[]} request.languageCodes + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see [Tags for + * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + * @param {string} request.deviceType + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * + * Supported formats: + * + * * `UNKNOWN_DEVICE_TYPE` + * + * * `DESKTOP` + * + * * `MOBILE` + * + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + * @param {string} request.dataset + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * {@link google.cloud.retail.v2alpha.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * + * Current supported values: + * + * * user-data + * + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + * @param {number} request.maxSuggestions + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. + * + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2alpha.CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/completion_service.complete_query.js + * region_tag:retail_v2alpha_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|undefined, {}|undefined + ]>; + completeQuery( + request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + +/** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog which the suggestions dataset belongs to. + * + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2alpha.CompletionDataInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js + * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async + */ + importCompletionData( + request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importCompletionData( + request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importCompletionData(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importCompletionData()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js + * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async + */ + async checkImportCompletionDataProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json new file mode 100644 index 00000000..ac2795a5 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json @@ -0,0 +1,45 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.CompletionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ImportCompletionData": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts new file mode 100644 index 00000000..bef33ee7 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts @@ -0,0 +1,1195 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/control_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './control_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for modifying Control. + * @class + * @memberof v2alpha + */ +export class ControlServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + controlServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ControlServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ControlServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listControls: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'controls') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.ControlService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.controlServiceStub) { + return this.controlServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ControlService. + this.controlServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ControlService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ControlService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const controlServiceStubMethods = + ['createControl', 'deleteControl', 'updateControl', 'getControl', 'listControls']; + for (const methodName of controlServiceStubMethods) { + const callPromise = this.controlServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.controlServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a Control. + * + * If the {@link google.cloud.retail.v2alpha.Control|Control} to create already + * exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent catalog. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {google.cloud.retail.v2alpha.Control} request.control + * Required. The Control to create. + * @param {string} request.controlId + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.create_control.js + * region_tag:retail_v2alpha_generated_ControlService_CreateControl_async + */ + createControl( + request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|undefined, {}|undefined + ]>; + createControl( + request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createControl(request, options, callback); + } +/** + * Deletes a Control. + * + * If the {@link google.cloud.retail.v2alpha.Control|Control} to delete does not + * exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.delete_control.js + * region_tag:retail_v2alpha_generated_ControlService_DeleteControl_async + */ + deleteControl( + request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|undefined, {}|undefined + ]>; + deleteControl( + request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteControl(request, options, callback); + } +/** + * Updates a Control. + * + * {@link google.cloud.retail.v2alpha.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link google.cloud.retail.v2alpha.Control|Control} to delete does not exist, a + * NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Control} request.control + * Required. The Control to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.Control|Control} to update. The following are + * NOT supported: + * + * * {@link google.cloud.retail.v2alpha.Control.name|Control.name} + * + * If not set or empty, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.update_control.js + * region_tag:retail_v2alpha_generated_ControlService_UpdateControl_async + */ + updateControl( + request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|undefined, {}|undefined + ]>; + updateControl( + request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'control.name': request.control!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateControl(request, options, callback); + } +/** + * Gets a Control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.get_control.js + * region_tag:retail_v2alpha_generated_ControlService_GetControl_async + */ + getControl( + request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|undefined, {}|undefined + ]>; + getControl( + request: protos.google.cloud.retail.v2alpha.IGetControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request: protos.google.cloud.retail.v2alpha.IGetControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Control]{@link google.cloud.retail.v2alpha.Control}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControls( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl[], + protos.google.cloud.retail.v2alpha.IListControlsRequest|null, + protos.google.cloud.retail.v2alpha.IListControlsResponse + ]>; + listControls( + request: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IControl>): void; + listControls( + request: protos.google.cloud.retail.v2alpha.IListControlsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IControl>): void; + listControls( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IControl>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IControl>): + Promise<[ + protos.google.cloud.retail.v2alpha.IControl[], + protos.google.cloud.retail.v2alpha.IListControlsRequest|null, + protos.google.cloud.retail.v2alpha.IListControlsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listControls(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Control]{@link google.cloud.retail.v2alpha.Control} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControlsStream( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.createStream( + this.innerApiCalls.listControls as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listControls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Control]{@link google.cloud.retail.v2alpha.Control}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.list_controls.js + * region_tag:retail_v2alpha_generated_ControlService_ListControls_async + */ + listControlsAsync( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.asyncIterate( + this.innerApiCalls['listControls'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.controlServiceStub && !this._terminated) { + return this.controlServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json new file mode 100644 index 00000000..9a86d786 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ControlService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListControls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json b/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json new file mode 100644 index 00000000..aeabbe19 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json @@ -0,0 +1,581 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.retail.v2alpha", + "libraryPackage": "@google-cloud/retail", + "services": { + "CatalogService": { + "clients": { + "grpc": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + } + } + }, + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + } + } + }, + "ControlService": { + "clients": { + "grpc": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "ProductService": { + "clients": { + "grpc": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "ServingConfigService": { + "clients": { + "grpc": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/index.ts b/owl-bot-staging/v2alpha/src/v2alpha/index.ts new file mode 100644 index 00000000..a7e4f6ba --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/index.ts @@ -0,0 +1,26 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CatalogServiceClient} from './catalog_service_client'; +export {CompletionServiceClient} from './completion_service_client'; +export {ControlServiceClient} from './control_service_client'; +export {PredictionServiceClient} from './prediction_service_client'; +export {ProductServiceClient} from './product_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {ServingConfigServiceClient} from './serving_config_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts new file mode 100644 index 00000000..6a5d9153 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts @@ -0,0 +1,837 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/prediction_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './prediction_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for making recommendation prediction. + * @class + * @memberof v2alpha + */ +export class PredictionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + predictionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PredictionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PredictionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.PredictionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.predictionServiceStub) { + return this.predictionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.PredictionService. + this.predictionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.PredictionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.PredictionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const predictionServiceStubMethods = + ['predict']; + for (const methodName of predictionServiceStubMethods) { + const callPromise = this.predictionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.predictionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Makes a recommendation prediction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see [Managing + * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * @param {number} request.pageSize + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * @param {string} request.pageToken + * The previous PredictResponse.next_page_token. + * @param {string} request.filter + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * + * Examples: + * + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * @param {boolean} request.validateOnly + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the predictions. + * + * Allowed values: + * + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2alpha.PredictResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/prediction_service.predict.js + * region_tag:retail_v2alpha_generated_PredictionService_Predict_async + */ + predict( + request?: protos.google.cloud.retail.v2alpha.IPredictRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|undefined, {}|undefined + ]>; + predict( + request: protos.google.cloud.retail.v2alpha.IPredictRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request: protos.google.cloud.retail.v2alpha.IPredictRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request?: protos.google.cloud.retail.v2alpha.IPredictRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.predictionServiceStub && !this._terminated) { + return this.predictionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json new file mode 100644 index 00000000..ed48fe50 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.PredictionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts new file mode 100644 index 00000000..0d593a5e --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts @@ -0,0 +1,2641 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/product_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.retail.v2alpha.Product|Product} + * information of the customer's website. + * @class + * @memberof v2alpha + */ +export class ProductServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProductServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeProductsResponse') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeProductsMetadata') as gax.protobuf.Type; + const importProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportProductsResponse') as gax.protobuf.Type; + const importProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; + const setInventoryResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.SetInventoryResponse') as gax.protobuf.Type; + const setInventoryMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.SetInventoryMetadata') as gax.protobuf.Type; + const addFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse') as gax.protobuf.Type; + const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; + const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; + const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; + const addLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddLocalInventoriesResponse') as gax.protobuf.Type; + const addLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata') as gax.protobuf.Type; + const removeLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse') as gax.protobuf.Type; + const removeLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)), + importProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductsResponse.decode.bind(importProductsResponse), + importProductsMetadata.decode.bind(importProductsMetadata)), + setInventory: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInventoryResponse.decode.bind(setInventoryResponse), + setInventoryMetadata.decode.bind(setInventoryMetadata)), + addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), + addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), + removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), + removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), + addLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), + addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), + removeLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), + removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.ProductService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.productServiceStub) { + return this.productServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ProductService. + this.productServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ProductService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ProductService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const productServiceStubMethods = + ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'purgeProducts', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; + for (const methodName of productServiceStubMethods) { + const callPromise = this.productServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.productServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + * @param {google.cloud.retail.v2alpha.Product} request.product + * Required. The {@link google.cloud.retail.v2alpha.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the + * {@link google.cloud.retail.v2alpha.Product|Product}, which will become the final + * component of the {@link google.cloud.retail.v2alpha.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * This field must be unique among all + * {@link google.cloud.retail.v2alpha.Product|Product}s with the same + * {@link google.cloud.retail.v2alpha.CreateProductRequest.parent|parent}. + * Otherwise, an ALREADY_EXISTS error is returned. + * + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.create_product.js + * region_tag:retail_v2alpha_generated_ProductService_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link google.cloud.retail.v2alpha.Product|Product} does not + * exist, a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.get_product.js + * region_tag:retail_v2alpha_generated_ProductService_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.retail.v2alpha.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.retail.v2alpha.IGetProductRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Updates a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Product} request.product + * Required. The product to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not + * exist and + * {@link google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing|allow_missing} + * is not set, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.Product|Product} to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, a new {@link google.cloud.retail.v2alpha.Product|Product} will be + * created. In this situation, `update_mask` is ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.update_product.js + * region_tag:retail_v2alpha_generated_ProductService_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Deletes a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to delete does not + * exist, a NOT_FOUND error is returned. + * + * The {@link google.cloud.retail.v2alpha.Product|Product} to delete can neither be + * a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} member nor a + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} with more than one + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link google.cloud.retail.v2alpha.Product|Product} will be deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.delete_product.js + * region_tag:retail_v2alpha_generated_ProductService_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } + +/** + * Permanently deletes all selected + * {@link google.cloud.retail.v2alpha.Product|Product}s under a branch. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed offline. Depending on the number of + * {@link google.cloud.retail.v2alpha.Product|Product}s, this operation could take + * hours to complete. Before the operation completes, some + * {@link google.cloud.retail.v2alpha.Product|Product}s may still be returned by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * Depending on the number of {@link google.cloud.retail.v2alpha.Product|Product}s, + * this operation could take hours to complete. To get a sample of + * {@link google.cloud.retail.v2alpha.Product|Product}s that would be deleted, set + * {@link google.cloud.retail.v2alpha.PurgeProductsRequest.force|PurgeProductsRequest.force} + * to false. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the branch under which the products are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` + * @param {string} request.filter + * Required. The filter string to specify the products to be deleted with a + * length limit of 5,000 characters. + * + * Empty string filter is not allowed. "*" implies delete all items in a + * branch. + * + * The eligible fields for filtering are: + * + * * `availability`: Double quoted + * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} + * string. + * * `create_time` : in ISO 8601 "zulu" format. + * + * Supported syntax: + * + * * Comparators (">", "<", ">=", "<=", "="). + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" + * * availability = "IN_STOCK" + * + * * Conjunctions ("AND") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" + * + * * Disjunctions ("OR") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" + * + * * Can support nested queries. + * Examples: + * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") + * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") + * + * * Filter Limits: + * * Filter should not contain more than 6 conditions. + * * Max nesting depth should not exceed 2 levels. + * + * Examples queries: + * * Delete back order products created before a timestamp. + * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.purge_products.js + * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.retail.v2alpha.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' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.purge_products.js + * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async + */ + async checkPurgeProductsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeProducts, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Bulk import of multiple {@link google.cloud.retail.v2alpha.Product|Product}s. + * + * Request processing may be synchronous. No partial updating is supported. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * {@link google.cloud.retail.v2alpha.Product|Product}s to be successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + * @param {string} request.requestId + * Deprecated. This field has no effect. + * @param {google.cloud.retail.v2alpha.ProductInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + * @param {google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * {@link google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * + * Only supported when + * {@link google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} + * is set to `FULL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.import_products.js + * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async + */ + importProducts( + request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProducts( + request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.import_products.js + * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async + */ + async checkImportProductsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates inventory information for a + * {@link google.cloud.retail.v2alpha.Product|Product} while respecting the last + * update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, updates are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct}, + * the specified inventory field value(s) will overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update time for the specified inventory fields will be overwritten to the + * time of the + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2alpha.CreateProductRequest.product|CreateProductRequest.product}, + * then any pre-existing inventory information for this product will be used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information will be preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2alpha.ProductService.SetInventory|SetInventory}, + * {@link google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Product} request.inventory + * Required. The inventory information to update. The allowable fields to + * update are: + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.Product|Product} named in + * {@link google.cloud.retail.v2alpha.Product.name|Product.name}, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to update has + * existing inventory information, the provided inventory information will be + * merged while respecting the last update time for each inventory field, + * using the provided or default value for + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. + * + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} + * + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link |SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} + * + * The last update time is recorded for the following inventory fields: + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, {@link |UpdateProduct} should be invoked instead. + * @param {google.protobuf.FieldMask} request.setMask + * Indicates which inventory fields in the provided + * {@link google.cloud.retail.v2alpha.Product|Product} to update. + * + * At least one field must be provided. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.setTime + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} with + * name {@link google.cloud.retail.v2alpha.Product.name|Product.name} is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the {@link google.cloud.retail.v2alpha.Product|Product} is created. If set + * to false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.set_inventory.js + * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async + */ + setInventory( + request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInventory( + request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'inventory.name': request.inventory!.name || '', + }); + this.initialize(); + return this.innerApiCalls.setInventory(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInventory()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.set_inventory.js + * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async + */ + async checkSetInventoryProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally adds place IDs to + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}. + * Duplicate IDs will be automatically ignored. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * If the total number of place IDs exceeds 2000 for this + * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type} after + * adding, then the update will be rejected. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async + */ + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async + */ + async checkAddFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally removes place IDs from a + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async + */ + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async + */ + async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates local inventory information for a + * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {number[]} request.localInventories + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + * @param {google.protobuf.FieldMask} request.addMask + * Indicates which inventory fields in the provided list of + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory} to update. The + * field is updated to the provided value. + * + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async + */ + addLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addLocalInventories( + request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async + */ + async checkAddLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Remove local inventory information for a + * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places at a + * removal timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {string[]} request.placeIds + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async + */ + removeLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeLocalInventories( + request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async + */ + async checkRemoveLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.retail.v2alpha.Product|Product}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} or + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.requireTotalSize + * If true and + * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} + * is set to the total count of matched items irrespective of pagination. + * + * Notice that setting this field to true affects the performance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.retail.v2alpha.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct[], + protos.google.cloud.retail.v2alpha.IListProductsRequest|null, + protos.google.cloud.retail.v2alpha.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IProduct>): void; + listProducts( + request: protos.google.cloud.retail.v2alpha.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IProduct>): void; + listProducts( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IProduct>): + Promise<[ + protos.google.cloud.retail.v2alpha.IProduct[], + protos.google.cloud.retail.v2alpha.IListProductsRequest|null, + protos.google.cloud.retail.v2alpha.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} or + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.requireTotalSize + * If true and + * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} + * is set to the total count of matched items irrespective of pagination. + * + * Notice that setting this field to true affects the performance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2alpha.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} or + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.requireTotalSize + * If true and + * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} + * is set to the total count of matched items irrespective of pagination. + * + * Notice that setting this field to true affects the performance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.retail.v2alpha.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.list_products.js + * region_tag:retail_v2alpha_generated_ProductService_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.productServiceStub && !this._terminated) { + return this.productServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json new file mode 100644 index 00000000..416ef1ec --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json @@ -0,0 +1,104 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ProductService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "GetProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ListProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "UpdateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "DeleteProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "PurgeProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportProducts": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "SetInventory": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts new file mode 100644 index 00000000..5e93921a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts @@ -0,0 +1,1537 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2alpha + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + search: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.SearchService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.SearchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.SearchService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const searchServiceStubMethods = + ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold + * The relevance threshold of the search results. + * + * Defaults to + * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2alpha.ISearchRequest|null, + protos.google.cloud.retail.v2alpha.ISearchResponse + ]>; + search( + request: protos.google.cloud.retail.v2alpha.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): void; + search( + request: protos.google.cloud.retail.v2alpha.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): void; + search( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): + Promise<[ + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2alpha.ISearchRequest|null, + protos.google.cloud.retail.v2alpha.ISearchResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold + * The relevance threshold of the search results. + * + * Defaults to + * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `search`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold + * The relevance threshold of the search results. + * + * Defaults to + * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/search_service.search.js + * region_tag:retail_v2alpha_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json new file mode 100644 index 00000000..71a5a478 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.SearchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts new file mode 100644 index 00000000..1df816d8 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts @@ -0,0 +1,1334 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/serving_config_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './serving_config_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for modifying ServingConfig. + * @class + * @memberof v2alpha + */ +export class ServingConfigServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + servingConfigServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServingConfigServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServingConfigServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listServingConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'servingConfigs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.ServingConfigService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.servingConfigServiceStub) { + return this.servingConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ServingConfigService. + this.servingConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ServingConfigService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ServingConfigService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const servingConfigServiceStubMethods = + ['createServingConfig', 'deleteServingConfig', 'updateServingConfig', 'getServingConfig', 'listServingConfigs', 'addControl', 'removeControl']; + for (const methodName of servingConfigServiceStubMethods) { + const callPromise = this.servingConfigServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.servingConfigServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a ServingConfig. + * + * A maximum of 100 + * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig}s are allowed in + * a {@link google.cloud.retail.v2alpha.Catalog|Catalog}, otherwise a + * FAILED_PRECONDITION error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig + * Required. The ServingConfig to create. + * @param {string} request.servingConfigId + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.create_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async + */ + createServingConfig( + request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|undefined, {}|undefined + ]>; + createServingConfig( + request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createServingConfig(request, options, callback); + } +/** + * Deletes a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.delete_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async + */ + deleteServingConfig( + request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|undefined, {}|undefined + ]>; + deleteServingConfig( + request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteServingConfig(request, options, callback); + } +/** + * Updates a ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig + * Required. The ServingConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2alpha.ServingConfig.name|ServingConfig.name} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.update_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async + */ + updateServingConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|undefined, {}|undefined + ]>; + updateServingConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config.name': request.servingConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateServingConfig(request, options, callback); + } +/** + * Gets a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.get_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_GetServingConfig_async + */ + getServingConfig( + request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|undefined, {}|undefined + ]>; + getServingConfig( + request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getServingConfig(request, options, callback); + } +/** + * Enables a Control on the specified ServingConfig. + * The control is added in the last position of the list of controls + * it belongs to (e.g. if it's a facet spec control it will be applied + * in the last position of servingConfig.facetSpecIds) + * Returns a ALREADY_EXISTS error if the control has already been applied. + * Returns a FAILED_PRECONDITION error if the addition could exceed maximum + * number of control allowed for that type of control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.add_control.js + * region_tag:retail_v2alpha_generated_ServingConfigService_AddControl_async + */ + addControl( + request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|undefined, {}|undefined + ]>; + addControl( + request: protos.google.cloud.retail.v2alpha.IAddControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request: protos.google.cloud.retail.v2alpha.IAddControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config': request.servingConfig || '', + }); + this.initialize(); + return this.innerApiCalls.addControl(request, options, callback); + } +/** + * Disables a Control on the specified ServingConfig. + * The control is removed from the ServingConfig. + * Returns a NOT_FOUND error if the Control is not enabled for the + * ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.remove_control.js + * region_tag:retail_v2alpha_generated_ServingConfigService_RemoveControl_async + */ + removeControl( + request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|undefined, {}|undefined + ]>; + removeControl( + request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config': request.servingConfig || '', + }); + this.initialize(); + return this.innerApiCalls.removeControl(request, options, callback); + } + + /** + * Lists all ServingConfigs linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigs( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig[], + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + ]>; + listServingConfigs( + request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IServingConfig>): void; + listServingConfigs( + request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IServingConfig>): void; + listServingConfigs( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IServingConfig>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IServingConfig>): + Promise<[ + protos.google.cloud.retail.v2alpha.IServingConfig[], + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listServingConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigsStream( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.createStream( + this.innerApiCalls.listServingConfigs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServingConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.list_serving_configs.js + * region_tag:retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async + */ + listServingConfigsAsync( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.asyncIterate( + this.innerApiCalls['listServingConfigs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.servingConfigServiceStub && !this._terminated) { + return this.servingConfigServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json new file mode 100644 index 00000000..6489c5db --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ServingConfigService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServingConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts new file mode 100644 index 00000000..bde84f81 --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts @@ -0,0 +1,1201 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on the customer website. + * @class + * @memberof v2alpha + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const purgeUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeUserEventsResponse') as gax.protobuf.Type; + const purgeUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeMetadata') as gax.protobuf.Type; + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportUserEventsResponse') as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; + const rejoinUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RejoinUserEventsResponse') as gax.protobuf.Type; + const rejoinUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RejoinUserEventsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), + purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata)), + rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), + rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.UserEventService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.UserEventService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.UserEventService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const userEventServiceStubMethods = + ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2alpha.UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.write_user_event.js + * region_tag:retail_v2alpha_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|undefined, {}|undefined + ]>; + writeUserEvent( + request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } +/** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.collect_user_event.js + * region_tag:retail_v2alpha_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|undefined, {}|undefined + ]>; + collectUserEvent( + request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + +/** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + * @param {string} request.filter + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * + * * `eventType`: Double quoted + * {@link google.cloud.retail.v2alpha.UserEvent.event_type|UserEvent.event_type} + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * + * Examples: + * + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * + * The filtering fields are assumed to have an implicit AND. + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async + */ + purgeUserEvents( + request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeUserEvents( + request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.purgeUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async + */ + async checkPurgeUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. `projects/1234/locations/global/catalogs/default_catalog` + * @param {google.cloud.retail.v2alpha.UserEventInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importUserEvents( + request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a user event rejoin operation with latest product catalog. Events + * will not be annotated with detailed product information if product is + * missing from the catalog at the time the user event is ingested, and these + * events are stored as unjoined events with a limited usage on training and + * serving. This method can be used to start a join operation on specified + * events with latest version of product catalog. It can also be used to + * correct events joined with the wrong product catalog. A rejoin operation + * can take hours or days to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async + */ + rejoinUserEvents( + request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rejoinUserEvents( + request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.rejoinUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rejoinUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async + */ + async checkRejoinUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json new file mode 100644 index 00000000..21dfac2e --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.UserEventService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "CollectUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "PurgeUserEvents": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportUserEvents": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "RejoinUserEvents": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json new file mode 100644 index 00000000..3355857a --- /dev/null +++ b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..57b7c7be --- /dev/null +++ b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js @@ -0,0 +1,34 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const retail = require('@google-cloud/retail'); + +function main() { + const catalogServiceClient = new retail.CatalogServiceClient(); + const completionServiceClient = new retail.CompletionServiceClient(); + const controlServiceClient = new retail.ControlServiceClient(); + const predictionServiceClient = new retail.PredictionServiceClient(); + const productServiceClient = new retail.ProductServiceClient(); + const searchServiceClient = new retail.SearchServiceClient(); + const servingConfigServiceClient = new retail.ServingConfigServiceClient(); + const userEventServiceClient = new retail.UserEventServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..25eaae42 --- /dev/null +++ b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts @@ -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. ** + +import {CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient} from '@google-cloud/retail'; + +// check that the client class type name can be used +function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { + client.close(); +} +function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { + client.close(); +} +function doStuffWithControlServiceClient(client: ControlServiceClient) { + client.close(); +} +function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { + client.close(); +} +function doStuffWithProductServiceClient(client: ProductServiceClient) { + client.close(); +} +function doStuffWithSearchServiceClient(client: SearchServiceClient) { + client.close(); +} +function doStuffWithServingConfigServiceClient(client: ServingConfigServiceClient) { + client.close(); +} +function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const catalogServiceClient = new CatalogServiceClient(); + doStuffWithCatalogServiceClient(catalogServiceClient); + // check that the client instance can be created + const completionServiceClient = new CompletionServiceClient(); + doStuffWithCompletionServiceClient(completionServiceClient); + // check that the client instance can be created + const controlServiceClient = new ControlServiceClient(); + doStuffWithControlServiceClient(controlServiceClient); + // check that the client instance can be created + const predictionServiceClient = new PredictionServiceClient(); + doStuffWithPredictionServiceClient(predictionServiceClient); + // check that the client instance can be created + const productServiceClient = new ProductServiceClient(); + doStuffWithProductServiceClient(productServiceClient); + // check that the client instance can be created + const searchServiceClient = new SearchServiceClient(); + doStuffWithSearchServiceClient(searchServiceClient); + // check that the client instance can be created + const servingConfigServiceClient = new ServingConfigServiceClient(); + doStuffWithServingConfigServiceClient(servingConfigServiceClient); + // check that the client instance can be created + const userEventServiceClient = new UserEventServiceClient(); + doStuffWithUserEventServiceClient(userEventServiceClient); +} + +main(); diff --git a/owl-bot-staging/v2alpha/system-test/install.ts b/owl-bot-staging/v2alpha/system-test/install.ts new file mode 100644 index 00000000..8ec45222 --- /dev/null +++ b/owl-bot-staging/v2alpha/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/v2alpha/test/gapic_catalog_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts new file mode 100644 index 00000000..017ab407 --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts @@ -0,0 +1,1790 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as catalogserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.CatalogServiceClient', () => { + it('has servicePath', () => { + const servicePath = catalogserviceModule.v2alpha.CatalogServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = catalogserviceModule.v2alpha.CatalogServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = catalogserviceModule.v2alpha.CatalogServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + await client.initialize(); + assert(client.catalogServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.catalogServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('updateCatalog', () => { + it('invokes updateCatalog without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); + const [response] = await client.updateCatalog(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCatalog( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICatalog|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCatalog with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCatalog(request), expectedError); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCatalog(request), expectedError); + }); + }); + + describe('setDefaultBranch', () => { + it('invokes setDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultBranch( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultBranch(request), expectedError); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultBranch(request), expectedError); + }); + }); + + describe('getDefaultBranch', () => { + it('invokes getDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.getDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDefaultBranch( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDefaultBranch(request), expectedError); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDefaultBranch(request), expectedError); + }); + }); + + describe('getCompletionConfig', () => { + it('invokes getCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); + client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCompletionConfig(request), expectedError); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCompletionConfig(request), expectedError); + }); + }); + + describe('updateCompletionConfig', () => { + it('invokes updateCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); + client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + }); + }); + + describe('getAttributesConfig', () => { + it('invokes getAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAttributesConfig(request), expectedError); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAttributesConfig(request), expectedError); + }); + }); + + describe('updateAttributesConfig', () => { + it('invokes updateAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + }); + }); + + describe('addCatalogAttribute', () => { + it('invokes addCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.addCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + }); + }); + + describe('removeCatalogAttribute', () => { + it('invokes removeCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.removeCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + }); + }); + + describe('replaceCatalogAttribute', () => { + it('invokes replaceCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.replaceCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes replaceCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.replaceCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes replaceCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes replaceCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + }); + }); + + describe('listCatalogs', () => { + it('invokes listCatalogs without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.listCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogs without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCatalogs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICatalog[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCatalogs with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCatalogs(request), expectedError); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogsStream without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCatalogsStream with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; + const iterable = client.listCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts new file mode 100644 index 00000000..c3aba50c --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts @@ -0,0 +1,703 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as completionserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2alpha.CompletionServiceClient', () => { + it('has servicePath', () => { + const servicePath = completionserviceModule.v2alpha.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = completionserviceModule.v2alpha.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v2alpha.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompleteQueryResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('importCompletionData', () => { + it('invokes importCompletionData without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); + const [operation] = await client.importCompletionData(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData without error using callback', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCompletionData( + request, + (err?: Error|null, + result?: LROperation|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.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importCompletionData with call error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importCompletionData(request), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData with LRO error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportCompletionDataProgress without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportCompletionDataProgress with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts new file mode 100644 index 00000000..4f62d30a --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts @@ -0,0 +1,1108 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as controlserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.ControlServiceClient', () => { + it('has servicePath', () => { + const servicePath = controlserviceModule.v2alpha.ControlServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = controlserviceModule.v2alpha.ControlServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = controlserviceModule.v2alpha.ControlServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + await client.initialize(); + assert(client.controlServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.controlServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createControl', () => { + it('invokes createControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); + const [response] = await client.createControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createControl(request), expectedError); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createControl(request), expectedError); + }); + }); + + describe('deleteControl', () => { + it('invokes deleteControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteControl( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteControl(request), expectedError); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteControl(request), expectedError); + }); + }); + + describe('updateControl', () => { + it('invokes updateControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); + const [response] = await client.updateControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateControl(request), expectedError); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateControl(request), expectedError); + }); + }); + + describe('getControl', () => { + it('invokes getControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); + const [response] = await client.getControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); + client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getControl(request), expectedError); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getControl(request), expectedError); + }); + }); + + describe('listControls', () => { + it('invokes listControls without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); + const [response] = await client.listControls(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listControls without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listControls( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listControls with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listControls(request), expectedError); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listControlsStream without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.descriptors.page.listControls.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Control) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listControls, request)); + assert.strictEqual( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listControlsStream with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Control) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listControls, request)); + assert.strictEqual( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listControls without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; + const iterable = client.listControlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listControls with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listControlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts new file mode 100644 index 00000000..d449dd3b --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts @@ -0,0 +1,543 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as predictionserviceModule from '../src'; + +import {protobuf} 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('v2alpha.PredictionServiceClient', () => { + it('has servicePath', () => { + const servicePath = predictionserviceModule.v2alpha.PredictionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = predictionserviceModule.v2alpha.PredictionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = predictionserviceModule.v2alpha.PredictionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + await client.initialize(); + assert(client.predictionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.predictionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('predict', () => { + it('invokes predict without error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCall(expectedResponse); + const [response] = await client.predict(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict without error using callback', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.predict( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IPredictResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes predict with error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict with closed client', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); + request.placement = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts new file mode 100644 index 00000000..ad57c1e0 --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts @@ -0,0 +1,2190 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as productserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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('v2alpha.ProductServiceClient', () => { + it('has servicePath', () => { + const servicePath = productserviceModule.v2alpha.ProductServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productserviceModule.v2alpha.ProductServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productserviceModule.v2alpha.ProductServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productserviceModule.v2alpha.ProductServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + await client.initialize(); + assert(client.productServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeProductsRequest()); + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importProducts', () => { + it('invokes importProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProducts( + request, + (err?: Error|null, + result?: LROperation|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.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProducts with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProducts(request), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductsProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductsProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInventory', () => { + it('invokes setInventory without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInventory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInventory( + request, + (err?: Error|null, + result?: LROperation|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.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setInventory with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInventory(request), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkSetInventoryProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInventoryProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInventoryProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addFulfillmentPlaces', () => { + it('invokes addFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeFulfillmentPlaces', () => { + it('invokes removeFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addLocalInventories', () => { + it('invokes addLocalInventories without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.addLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addLocalInventories with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addLocalInventories(request), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeLocalInventories', () => { + it('invokes removeLocalInventories without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeLocalInventories with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeLocalInventories(request), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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.retail.v2alpha.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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.retail.v2alpha.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts new file mode 100644 index 00000000..4c28a3a6 --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts @@ -0,0 +1,770 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.SearchServiceClient', () => { + it('has servicePath', () => { + const servicePath = searchserviceModule.v2alpha.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = searchserviceModule.v2alpha.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v2alpha.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts new file mode 100644 index 00000000..f3a80ec9 --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts @@ -0,0 +1,1302 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as servingconfigserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.ServingConfigServiceClient', () => { + it('has servicePath', () => { + const servicePath = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + await client.initialize(); + assert(client.servingConfigServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servingConfigServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createServingConfig', () => { + it('invokes createServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.createServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createServingConfig(request), expectedError); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createServingConfig(request), expectedError); + }); + }); + + describe('deleteServingConfig', () => { + it('invokes deleteServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServingConfig( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteServingConfig(request), expectedError); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteServingConfig(request), expectedError); + }); + }); + + describe('updateServingConfig', () => { + it('invokes updateServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateServingConfig(request), expectedError); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateServingConfig(request), expectedError); + }); + }); + + describe('getServingConfig', () => { + it('invokes getServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getServingConfig(request), expectedError); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getServingConfig(request), expectedError); + }); + }); + + describe('addControl', () => { + it('invokes addControl without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); + const [response] = await client.addControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addControl with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addControl(request), expectedError); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addControl with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); + request.servingConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addControl(request), expectedError); + }); + }); + + describe('removeControl', () => { + it('invokes removeControl without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); + const [response] = await client.removeControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); + client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeControl with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeControl(request), expectedError); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeControl with closed client', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); + request.servingConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeControl(request), expectedError); + }); + }); + + describe('listServingConfigs', () => { + it('invokes listServingConfigs without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listServingConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServingConfigs without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServingConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServingConfigs(request), expectedError); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServingConfigsStream without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + ]; + client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listServingConfigsStream with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServingConfigs without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), + ]; + client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = []; + const iterable = client.listServingConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServingConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts new file mode 100644 index 00000000..4da29c4b --- /dev/null +++ b/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts @@ -0,0 +1,1088 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as usereventserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2alpha.UserEventServiceClient', () => { + it('has servicePath', () => { + const servicePath = usereventserviceModule.v2alpha.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = usereventserviceModule.v2alpha.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v2alpha.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IUserEvent|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('purgeUserEvents', () => { + it('invokes purgeUserEvents without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeUserEvents with call error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeUserEvents(request), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rejoinUserEvents', () => { + it('invokes rejoinUserEvents without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.rejoinUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejoinUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes rejoinUserEvents with call error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRejoinUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRejoinUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2alpha/tsconfig.json b/owl-bot-staging/v2alpha/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v2alpha/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/v2alpha/webpack.config.js b/owl-bot-staging/v2alpha/webpack.config.js new file mode 100644 index 00000000..f2c58f25 --- /dev/null +++ b/owl-bot-staging/v2alpha/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CatalogService', + filename: './catalog-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v2beta/.eslintignore b/owl-bot-staging/v2beta/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v2beta/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v2beta/.eslintrc.json b/owl-bot-staging/v2beta/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v2beta/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v2beta/.gitignore b/owl-bot-staging/v2beta/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v2beta/.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/v2beta/.jsdoc.js b/owl-bot-staging/v2beta/.jsdoc.js new file mode 100644 index 00000000..19729810 --- /dev/null +++ b/owl-bot-staging/v2beta/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v2beta/.mocharc.js b/owl-bot-staging/v2beta/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v2beta/.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/v2beta/.prettierrc.js b/owl-bot-staging/v2beta/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v2beta/.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/v2beta/README.md b/owl-bot-staging/v2beta/README.md new file mode 100644 index 00000000..822c4573 --- /dev/null +++ b/owl-bot-staging/v2beta/README.md @@ -0,0 +1 @@ +Retail: Nodejs Client diff --git a/owl-bot-staging/v2beta/linkinator.config.json b/owl-bot-staging/v2beta/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v2beta/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/v2beta/package.json b/owl-bot-staging/v2beta/package.json new file mode 100644 index 00000000..94071ee3 --- /dev/null +++ b/owl-bot-staging/v2beta/package.json @@ -0,0 +1,71 @@ +{ + "name": "@google-cloud/retail", + "version": "0.1.0", + "description": "Retail client for Node.js", + "repository": "googleapis/nodejs-retail", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google retail", + "retail", + "catalog service", + "completion service", + "control service", + "prediction service", + "product service", + "search service", + "serving config service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto new file mode 100644 index 00000000..e0b844ef --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto @@ -0,0 +1,397 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configures what level the product should be uploaded with regards to +// how users will be send events and how predictions will be made. +message ProductLevelConfig { + // The type of [Product][google.cloud.retail.v2beta.Product]s allowed to be + // ingested into the catalog. Acceptable values are: + // + // * `primary` (default): You can ingest + // [Product][google.cloud.retail.v2beta.Product]s of all types. When + // ingesting a [Product][google.cloud.retail.v2beta.Product], its type will + // default to + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // if unset. + // * `variant`: You can only ingest + // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s. + // This means + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] + // cannot be empty. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `variant` and + // [merchant_center_product_id_field][google.cloud.retail.v2beta.ProductLevelConfig.merchant_center_product_id_field] + // is `itemGroupId`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string ingestion_product_type = 1; + + // Which field of [Merchant Center + // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be + // imported as [Product.id][google.cloud.retail.v2beta.Product.id]. Acceptable + // values are: + // + // * `offerId` (default): Import `offerId` as the product ID. + // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail + // API will choose one item from the ones with the same `itemGroupId`, and + // use it to represent the item group. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `itemGroupId` and + // [ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] + // is `variant`, an INVALID_ARGUMENT error is returned. + // + // See [Using product + // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // for more details. + string merchant_center_product_id_field = 2; +} + +// Catalog level attribute config for an attribute. For example, if customers +// want to enable/disable facet for a specific attribute. +message CatalogAttribute { + // The type of an attribute. + enum AttributeType { + // The type of the attribute is unknown. + // + // Used when type cannot be derived from attribute that is not + // [in_use][google.cloud.retail.v2beta.CatalogAttribute.in_use]. + UNKNOWN = 0; + + // Textual attribute. + TEXTUAL = 1; + + // Numerical attribute. + NUMERICAL = 2; + } + + // The status of the indexable option of a catalog attribute. + enum IndexableOption { + // Value used when unset. Defaults to + // [INDEXABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. + INDEXABLE_OPTION_UNSPECIFIED = 0; + + // Indexable option enabled for an attribute. + INDEXABLE_ENABLED = 1; + + // Indexable option disabled for an attribute. + INDEXABLE_DISABLED = 2; + } + + // The status of the dynamic facetable option of a catalog attribute. + enum DynamicFacetableOption { + // Value used when unset. Defaults to + // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; + + // Dynamic facetable option enabled for an attribute. + DYNAMIC_FACETABLE_ENABLED = 1; + + // Dynamic facetable option disabled for an attribute. + DYNAMIC_FACETABLE_DISABLED = 2; + } + + // The status of the searchable option of a catalog attribute. + enum SearchableOption { + // Value used when unset. Defaults to + // [SEARCHABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Indicates whether this attribute has been used by any + // products. `True` if at least one + // [Product][google.cloud.retail.v2beta.Product] is using this attribute in + // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. + // Otherwise, this field is `False`. + // + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] can be + // pre-loaded by using [AddCatalogAttribute][], [ImportCatalogAttributes][], + // or [UpdateAttributesConfig][] APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s. + // + // Only [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that + // are not in use by products can be deleted. + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that are + // in use by products cannot be deleted; however, their configuration + // properties will reset to default values upon removal request. + // + // After catalog changes, it takes about 10 minutes for this field to update. + bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The type of this attribute. This is derived from the attribute + // in [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. + AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values + // are indexed so that it can be filtered, faceted, or boosted in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + IndexableOption indexable_option = 5; + + // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic + // facet. Could only be DYNAMIC_FACETABLE_DISABLED if + // [CatalogAttribute.indexable_option][google.cloud.retail.v2beta.CatalogAttribute.indexable_option] + // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. + DynamicFacetableOption dynamic_facetable_option = 6; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values + // are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values + // will not be searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], as + // there are no text values associated to numerical attributes. + SearchableOption searchable_option = 7; +} + +// Catalog level attribute config. +message AttributesConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/AttributesConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }; + + // Required. Immutable. The fully qualified resource name of the attribute + // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Enable attribute(s) config at catalog level. + // For example, indexable, dynamic_facetable, or searchable for each + // attribute. + // + // The key is catalog attribute's name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // + // The maximum number of catalog attributes allowed in a request is 1000. + map catalog_attributes = 2; + + // Output only. The + // [AttributeConfigLevel][google.cloud.retail.v2beta.AttributeConfigLevel] + // used for this catalog. + AttributeConfigLevel attribute_config_level = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Catalog level autocomplete config for customers to customize autocomplete +// feature's settings. +message CompletionConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/CompletionConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }; + + // Required. Immutable. Fully qualified name + // `projects/*/locations/*/catalogs/*/completionConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Specifies the matching order for autocomplete suggestions, e.g., a query + // consisting of 'sh' with 'out-of-order' specified would suggest "women's + // shoes", whereas a query of 'red s' with 'exact-prefix' specified would + // suggest "red shoes". Currently supported values: + // + // * 'out-of-order' + // * 'exact-prefix' + // + // Default value: 'exact-prefix'. + string matching_order = 2; + + // The maximum number of autocomplete suggestions returned per term. The + // maximum allowed max suggestions is 20. Default value is 20. If left unset + // or set to 0, then will fallback to default value. + int32 max_suggestions = 3; + + // The minimum number of characters needed to be typed in order to get + // suggestions. Default value is 2. If left unset or set to 0, then will + // fallback to default value. + int32 min_prefix_length = 4; + + // If set to true, the auto learning function is enabled. Auto learning uses + // user data to generate suggestions using ML techniques. Default value is + // false. Only after enabling auto learning can users use `cloud-retail` + // data in + // [CompleteQueryRequest][google.cloud.retail.v2beta.CompleteQueryRequest]. + bool auto_learning = 11; + + // Output only. The input config for the import of the source data that + // contains the autocomplete phrases uploaded by the customer. + CompletionDataInputConfig suggestions_input_config = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest suggestion terms + // list import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_suggestions_import_operation = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The input config for the import of the source data that + // contains the / autocomplete denylist phrases uploaded by the customer. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. LRO corresponding to the latest denylist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_denylist_import_operation = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The input config for the import of the source data that + // contains the autocomplete allowlist phrases uploaded by the customer. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. LRO corresponding to the latest allowlist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_allowlist_import_operation = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Represents a link between a Merchant Center account and a branch. +// Once a link is established, products from the linked merchant center account +// will be streamed to the linked branch. +message MerchantCenterLink { + // Required. The linked [Merchant center account + // id](https://developers.google.com/shopping-content/guides/accountstatuses). + // The account must be a standalone account or a sub-account of a MCA. + int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch id (e.g. 0/1/2) within this catalog that products from + // merchant_center_account_id are streamed to. When updating this field, an + // empty value will use the currently configured default branch. However, + // changing the default branch later on won't change the linked branch here. + // + // A single branch id can only have one linked merchant center account id. + string branch_id = 2; + + // String representing the destination to import for, all if left empty. + // List of possible values can be found here. + // [https://support.google.com/merchants/answer/7501026] + // List of allowed string values: + // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory + // _ads", "Free_listings", "Free_local_listings" + // NOTE: The string values are case sensitive. + repeated string destinations = 3; + + // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 + // code. List of values can be found + // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) + // under the `region` tag. If left blank no region filtering will be + // performed. + // + // Example value: `US`. + string region_code = 4; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // ISO 639-1. + // + // This specifies the language of offers in Merchant Center that will be + // accepted. If empty no language filtering will be performed. + // + // Example value: `en`. + string language_code = 5; +} + +// Configures Merchant Center linking. +// Links contained in the config will be used to sync data from a Merchant +// Center account to a Cloud Retail branch. +message MerchantCenterLinkingConfig { + // Links between Merchant Center accounts and branches. + repeated MerchantCenterLink links = 1; +} + +// The catalog configuration. +message Catalog { + option (google.api.resource) = { + type: "retail.googleapis.com/Catalog" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" + }; + + // Required. Immutable. The fully qualified resource name of the catalog. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The catalog display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. The product level configuration. + ProductLevelConfig product_level_config = 4 + [(google.api.field_behavior) = REQUIRED]; + + // The Merchant Center linking configuration. + // Once a link is added, the data stream from Merchant Center to Cloud Retail + // will be enabled automatically. The requester must have access to the + // merchant center account in order to make changes to this field. + MerchantCenterLinkingConfig merchant_center_linking_config = 6; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto new file mode 100644 index 00000000..7e27c916 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto @@ -0,0 +1,478 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/catalog.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for managing catalog configuration. +service CatalogService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated + // with the project. + rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*}/catalogs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s. + rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { + option (google.api.http) = { + patch: "/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}" + body: "catalog" + }; + option (google.api.method_signature) = "catalog,update_mask"; + } + + // Set a specified branch id as default branch. API methods such as + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] + // will treat requests using "default_branch" to the actual branch id set as + // default. + // + // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + // default, setting + // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + // to setting + // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/1`. + // + // Using multiple branches can be useful when developers would like + // to have a staging branch to test and verify for future usage. When it + // becomes ready, developers switch on the staging branch using this API while + // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + // as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] + // to route the traffic to this staging branch. + // + // CAUTION: If you have live predict/search traffic, switching the default + // branch could potentially cause outages if the ID space of the new branch is + // very different from the old one. + // + // More specifically: + // + // * PredictionService will only return product IDs from branch {newBranch}. + // * SearchService will only return product IDs from branch {newBranch} + // (if branch is not explicitly set). + // * UserEventService will only join events with products from branch + // {newBranch}. + rpc SetDefaultBranch(SetDefaultBranchRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" + body: "*" + }; + option (google.api.method_signature) = "catalog"; + } + + // Get which branch is currently default branch set by + // [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] + // method under a specified parent catalog. + rpc GetDefaultBranch(GetDefaultBranchRequest) + returns (GetDefaultBranchResponse) { + option (google.api.http) = { + get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + }; + option (google.api.method_signature) = "catalog"; + } + + // Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]. + rpc GetCompletionConfig(GetCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s. + rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + patch: "/v2beta/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" + body: "completion_config" + }; + option (google.api.method_signature) = "completion_config,update_mask"; + } + + // Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + rpc GetAttributesConfig(GetAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + // + // The catalog attributes in the request will be updated in the catalog, or + // inserted if they do not exist. Existing catalog attributes not included in + // the request will remain unchanged. Attributes that are assigned to + // products, but do not exist at the catalog level, are always included in the + // response. The product attribute is assigned default values for missing + // catalog attribute fields, e.g., searchable and dynamic facetable options. + rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + patch: "/v2beta/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" + body: "attributes_config" + }; + option (google.api.method_signature) = "attributes_config,update_mask"; + } + + // Adds the specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to + // add already exists, an ALREADY_EXISTS error is returned. + rpc AddCatalogAttribute(AddCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" + body: "*" + }; + } + + // Removes the specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to + // remove does not exist, a NOT_FOUND error is returned. + rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" + body: "*" + }; + } + + // Replaces the specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating + // the catalog attribute with the same + // [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. + // + // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to + // replace does not exist, a NOT_FOUND error is returned. + rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" + body: "*" + }; + } +} + +// Request for +// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] +// method. +message ListCatalogsRequest { + // Required. The account resource name with an associated location. + // + // If the caller does not have permission to list + // [Catalog][google.cloud.retail.v2beta.Catalog]s under this location, + // regardless of whether or not this location exists, a PERMISSION_DENIED + // error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of [Catalog][google.cloud.retail.v2beta.Catalog]s to return. + // If unspecified, defaults to 50. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 2; + + // A page token + // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token], + // received from a previous + // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; +} + +// Response for +// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] +// method. +message ListCatalogsResponse { + // All the customer's [Catalog][google.cloud.retail.v2beta.Catalog]s. + repeated Catalog catalogs = 1; + + // A token that can be sent as + // [ListCatalogsRequest.page_token][google.cloud.retail.v2beta.ListCatalogsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request for +// [CatalogService.UpdateCatalog][google.cloud.retail.v2beta.CatalogService.UpdateCatalog] +// method. +message UpdateCatalogRequest { + // Required. The [Catalog][google.cloud.retail.v2beta.Catalog] to update. + // + // If the caller does not have permission to update the + // [Catalog][google.cloud.retail.v2beta.Catalog], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the [Catalog][google.cloud.retail.v2beta.Catalog] to update does not + // exist, a NOT_FOUND error is returned. + Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Catalog][google.cloud.retail.v2beta.Catalog] to update. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message to set a specified branch as new default_branch. +message SetDefaultBranchRequest { + // Full resource name of the catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // The final component of the resource name of a branch. + // + // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // If there are no sufficient active products in the targeted branch and + // [force][google.cloud.retail.v2beta.SetDefaultBranchRequest.force] is not + // set, a FAILED_PRECONDITION error is returned. + string branch_id = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Some note on this request, this can be retrieved by + // [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch] + // before next valid default branch set occurs. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string note = 3; + + // If set to true, it permits switching to a branch with + // [branch_id][google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id] + // even if it has no sufficient active products. + bool force = 4; +} + +// Request message to show which branch is currently the default branch. +message GetDefaultBranchRequest { + // The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response message of +// [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch]. +message GetDefaultBranchResponse { + // Full resource name of the branch id currently set as default branch. + string branch = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // The time when this branch is set to default. + google.protobuf.Timestamp set_time = 2; + + // This corresponds to + // [SetDefaultBranchRequest.note][google.cloud.retail.v2beta.SetDefaultBranchRequest.note] + // field, when this branch was set as default. + string note = 3; +} + +// Request for +// [CatalogService.GetCompletionConfig][google.cloud.retail.v2beta.CatalogService.GetCompletionConfig] +// method. +message GetCompletionConfigRequest { + // Required. Full CompletionConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/CompletionConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig] +// method. +message UpdateCompletionConfigRequest { + // Required. The + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. + // + // If the caller does not have permission to update the + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig], then a + // PERMISSION_DENIED error is returned. + // + // If the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to + // update does not exist, a NOT_FOUND error is returned. + CompletionConfig completion_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. + // The following are the only supported fields: + // + // * [CompletionConfig.matching_order][google.cloud.retail.v2beta.CompletionConfig.matching_order] + // * [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions] + // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2beta.CompletionConfig.min_prefix_length] + // * [CompletionConfig.auto_learning][google.cloud.retail.v2beta.CompletionConfig.auto_learning] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.GetAttributesConfig][google.cloud.retail.v2beta.CatalogService.GetAttributesConfig] +// method. +message GetAttributesConfigRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig] +// method. +message UpdateAttributesConfigRequest { + // Required. The + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. + AttributesConfig attributes_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. + // The following is the only supported field: + // + // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2beta.AttributesConfig.catalog_attributes] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute] +// method. +message AddCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute] +// method. +message RemoveCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The attribute name key of the + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove. + string key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute] +// method. +message ReplaceCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The updated + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to update. + // The following are NOT supported: + // + // * [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 3; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto new file mode 100644 index 00000000..ada7dd15 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto @@ -0,0 +1,760 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// At which level we offer configuration for attributes. +enum AttributeConfigLevel { + // Value used when unset. Defaults to + // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2beta.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; + + // At this level, we honor the attribute configurations set in + // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; + + // At this level, we honor the attribute configurations set in + // [CatalogConfig.attribute_configs][]. + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; +} + +// The type of solution. +enum SolutionType { + // Default value. + SOLUTION_TYPE_UNSPECIFIED = 0; + + // Used for Recommendations AI. + SOLUTION_TYPE_RECOMMENDATION = 1; + + // Used for Retail Search. + SOLUTION_TYPE_SEARCH = 2; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. Defaults to + // [SEARCH][]. + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; + + // Search use case. Expects the traffic has a non-empty + // [query][google.cloud.retail.v2beta.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_SEARCH = 1; + + // Browse use case. Expects the traffic has an empty + // [query][google.cloud.retail.v2beta.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_BROWSE = 2; +} + +// Metadata that is used to define a condition that triggers an action. +// A valid condition must specify at least one of 'query_terms' or +// 'products_filter'. If multiple fields are specified, the condition is met if +// all the fields are satisfied e.g. if a set of query terms and product_filter +// are set, then only items matching the product_filter for requests with a +// query matching the query terms wil get boosted. +message Condition { + // Query terms that we want to match on. + message QueryTerm { + // The value of the term to match on. + // Value cannot be empty. + // Value can have at most 3 terms if specified as a partial match. Each + // space separated string is considered as one term. + // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not + // allowed for partial match. + string value = 1; + + // Whether this is supposed to be a full or partial match. + bool full_match = 2; + } + + // Used for time-dependent conditions. + // Example: Want to have rule applied for week long sale. + message TimeRange { + // Start of time range. Range is inclusive. + google.protobuf.Timestamp start_time = 1; + + // End of time range. Range is inclusive. + google.protobuf.Timestamp end_time = 2; + } + + // A list (up to 10 entries) of terms to match the query on. If not + // specified, match all queries. + // If many query terms are specified, the condition + // is matched if any of the terms is a match (i.e. using the OR operator). + repeated QueryTerm query_terms = 1; + + // Range of time(s) specifying when Condition is active. + // Condition true if any time range matches. + repeated TimeRange active_time_range = 3; +} + +// A rule is a condition-action pair +// * A condition defines when a rule is to be triggered. +// * An action specifies what occurs on that trigger. +// Currently only boost rules are supported. +// Currently only supported by the search endpoint. +message Rule { + // A boost action to apply to results matching condition specified above. + message BoostAction { + // Strength of the condition boost, which must be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 1; + + // The filter can have a max size of 5000 characters. + // An expression which specifies which products to apply an action to. + // The syntax and supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string products_filter = 2; + } + + // * Rule Condition: + // - No [Condition][query_terms] provided is a global match. + // - 1 or more [Condition][query_terms] provided is combined with OR + // operator. + // * Action Input: The request query and filter that will be applied to the + // retrieved products, in addition to any filters already provided with the + // SearchRequest. The AND operator is used to combine the query's existing + // filters with the filter rule(s). NOTE: May result in 0 results when + // filters conflict. + // * Action Result: Filters the returned objects to be ONLY those that passed + // the filter. + message FilterAction { + // A filter to apply on the matching condition results. Supported features: + // + // * [filter][google.cloud.retail.v2beta.Rule.FilterAction.filter] must be + // set. + // * Filter syntax is identical to + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter]. + // See more + // details at the Retail Search + // [user guide](/retail/search/docs/filter-and-order#filter). + // * To filter products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string filter = 1; + } + + // Redirects a shopper to a specific page. + // * Rule Condition: + // - Must specify [Condition][query_terms]. + // * Action Input: Request Query + // * Action Result: Redirects shopper to provided uri. + message RedirectAction { + // URL must have length equal or less than 2000 characters. + string redirect_uri = 1; + } + + // Creates a set of terms that will be treated as synonyms of each other. + // Example: synonyms of "sneakers" and "shoes". + // * "sneakers" will use a synonym of "shoes". + // * "shoes" will use a synonym of "sneakers". + message TwowaySynonymsAction { + // Defines a set of synonyms. + // Can specify up to 100 synonyms. + // Must specify at least 2 synonyms. + repeated string synonyms = 1; + } + + // Maps a set of terms to a set of synonyms. + // Set of synonyms will be treated as synonyms of each query term only. + // `query_terms` will not be treated as synonyms of each other. + // Example: "sneakers" will use a synonym of "shoes". + // "shoes" will not use a synonym of "sneakers". + message OnewaySynonymsAction { + // Terms from the search query. + // Will treat synonyms as their synonyms. + // Not themselves synonyms of the synonyms. + // Can specify up to 100 terms. + repeated string query_terms = 3; + + // Defines a set of synonyms. + // Cannot contain duplicates. + // Can specify up to 100 synonyms. + repeated string synonyms = 4; + + // Will be [deprecated = true] post migration; + repeated string oneway_terms = 2; + } + + // Prevents `query_term` from being associated with specified terms during + // search. + // Example: Don't associate "gShoe" and "cheap". + message DoNotAssociateAction { + // Terms from the search query. + // Will not consider do_not_associate_terms for search if in search query. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Cannot contain duplicates or the query term. + // Can specify up to 100 terms. + repeated string do_not_associate_terms = 3; + + // Will be [deprecated = true] post migration; + repeated string terms = 1; + } + + // Replaces a term in the query. Multiple replacement candidates can be + // specified. All `query_terms` will be replaced with the replacement term. + // Example: Replace "gShoe" with "google shoe". + message ReplacementAction { + // Terms from the search query. + // Will be replaced by replacement term. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Term that will be used for replacement. + string replacement_term = 3; + + // Will be [deprecated = true] post migration; + string term = 1; + } + + // Prevents a term in the query from being used in search. + // Example: Don't search for "shoddy". + message IgnoreAction { + // Terms to ignore in the search query. + repeated string ignore_terms = 1; + } + + // An action must be provided. + oneof action { + // A boost action. + BoostAction boost_action = 2; + + // Redirects a shopper to a specific page. + RedirectAction redirect_action = 3; + + // Treats specific term as a synonym with a group of terms. + // Group of terms will not be treated as synonyms with the specific term. + OnewaySynonymsAction oneway_synonyms_action = 6; + + // Prevents term from being associated with other terms. + DoNotAssociateAction do_not_associate_action = 7; + + // Replaces specific terms in the query. + ReplacementAction replacement_action = 8; + + // Ignores specific terms from query during search. + IgnoreAction ignore_action = 9; + + // Filters results. + FilterAction filter_action = 10; + + // Treats a set of terms as synonyms of one another. + TwowaySynonymsAction twoway_synonyms_action = 11; + } + + // Required. The condition that triggers the rule. + // If the condition is empty, the rule will always apply. + Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// An intended audience of the [Product][google.cloud.retail.v2beta.Product] for +// whom it's sold. +message Audience { + // The genders of the audience. Strongly encouraged to use the standard + // values: "male", "female", "unisex". + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [gender](https://support.google.com/merchants/answer/6324479). Schema.org + // property + // [Product.audience.suggestedGender](https://schema.org/suggestedGender). + repeated string genders = 1; + + // The age groups of the audience. Strongly encouraged to use the standard + // values: "newborn" (up to 3 months old), "infant" (3–12 months old), + // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically + // teens or older). + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [age_group](https://support.google.com/merchants/answer/6324463). + // Schema.org property + // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and + // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). + repeated string age_groups = 2; +} + +// The color information of a [Product][google.cloud.retail.v2beta.Product]. +message ColorInfo { + // The standard color families. Strongly recommended to use the following + // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", + // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and + // "Mixed". Normally it is expected to have only 1 color family. May consider + // using single "Mixed" instead of multiple values. + // + // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string color_families = 1; + + // The color display names, which may be different from standard color family + // names, such as the color aliases used in the website frontend. Normally + // it is expected to have only 1 color. May consider using single "Mixed" + // instead of multiple values. + // + // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string colors = 2; +} + +// A custom attribute that is not explicitly modeled in +// [Product][google.cloud.retail.v2beta.Product]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated double numbers = 2; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2beta.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2beta.UserEvent]. + // + // Only set if type [text][google.cloud.retail.v2beta.CustomAttribute.text] is + // set. Otherwise, a INVALID_ARGUMENT error is returned. + optional bool searchable = 3; + + // This field will only be used when + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2beta.Catalog] is + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are + // indexed, so that it can be filtered, faceted or boosted in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2beta.UserEvent]. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter], + // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2beta.SearchRequest.boost_spec] + // for more details. + optional bool indexable = 4; +} + +// Fulfillment information, such as the store IDs for in-store pickup or region +// IDs for different shipping methods. +message FulfillmentInfo { + // The fulfillment type, including commonly used types (such as pickup in + // store and same day delivery), and custom types. Customers have to map + // custom types to their display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + string type = 1; + + // The IDs for this [type][google.cloud.retail.v2beta.FulfillmentInfo.type], + // such as the store IDs for + // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2beta.FulfillmentInfo.type] + // or the region IDs for + // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2beta.FulfillmentInfo.type]. + // + // A maximum of 3000 values are allowed. Each value must be a string with a + // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such + // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string place_ids = 2; +} + +// [Product][google.cloud.retail.v2beta.Product] image. Recommendations AI and +// Retail Search do not use product images to improve prediction and search +// results. However, product images can be returned in results, and are shown in +// prediction or search previews in the console. +message Image { + // Required. URI of the image. + // + // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Height of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 height = 2; + + // Width of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 width = 3; +} + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are set, then + // the lower bound is negative infinity. + // + // This field must be not larger than + // [max][google.cloud.retail.v2beta.Interval.max]. Otherwise, an + // INVALID_ARGUMENT error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are set, then + // the upper bound is positive infinity. + // + // This field must be not smaller than + // [min][google.cloud.retail.v2beta.Interval.min]. Otherwise, an + // INVALID_ARGUMENT error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// The price information of a [Product][google.cloud.retail.v2beta.Product]. +message PriceInfo { + // The price range of all + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. + message PriceRange { + // The inclusive + // [Product.pricing_info.price][google.cloud.retail.v2beta.PriceInfo.price] + // interval of all + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. + Interval price = 1; + + // The inclusive + // [Product.pricing_info.original_price][google.cloud.retail.v2beta.PriceInfo.original_price] + // internal of all + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. + Interval original_price = 2; + } + + // The 3-letter currency code defined in [ISO + // 4217](https://www.iso.org/iso-4217-currency-codes.html). + // + // If this field is an unrecognizable currency code, an INVALID_ARGUMENT + // error is returned. + // + // The [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s with the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] + // must share the same + // [currency_code][google.cloud.retail.v2beta.PriceInfo.currency_code]. + // Otherwise, a FAILED_PRECONDITION error is returned. + string currency_code = 1; + + // Price of the product. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). Schema.org + // property [Offer.price](https://schema.org/price). + float price = 2; + + // Price of the product without any discount. If zero, by default set to be + // the [price][google.cloud.retail.v2beta.PriceInfo.price]. + float original_price = 3; + + // The costs associated with the sale of a particular product. Used for gross + // profit reporting. + // + // * Profit = [price][google.cloud.retail.v2beta.PriceInfo.price] - + // [cost][google.cloud.retail.v2beta.PriceInfo.cost] + // + // Google Merchant Center property + // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). + float cost = 4; + + // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] + // starts to be effective. This can be set as a future timestamp, and the + // [price][google.cloud.retail.v2beta.PriceInfo.price] is only used for search + // after + // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. + // If so, the + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is + // used before + // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. + // + // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_effective_time = 5; + + // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] + // stops to be effective. The + // [price][google.cloud.retail.v2beta.PriceInfo.price] is used for search + // before + // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. + // If this field is set, the + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is + // used after + // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. + // + // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_expire_time = 6; + + // Output only. The price range of all the child + // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s grouped together on the + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]. Only populated for + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. + // Do not set this field in API requests. + PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The rating of a [Product][google.cloud.retail.v2beta.Product]. +message Rating { + // The total number of ratings. This value is independent of the value of + // [rating_histogram][google.cloud.retail.v2beta.Rating.rating_histogram]. + // + // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 rating_count = 1; + + // The average rating of the [Product][google.cloud.retail.v2beta.Product]. + // + // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is + // returned. + float average_rating = 2; + + // List of rating counts per rating value (index = rating - 1). The list is + // empty if there is no rating. If the list is non-empty, its size is + // always 5. Otherwise, an INVALID_ARGUMENT error is returned. + // + // For example, [41, 14, 13, 47, 303]. It means that the + // [Product][google.cloud.retail.v2beta.Product] got 41 ratings with 1 star, + // 14 ratings with 2 star, and so on. + repeated int32 rating_histogram = 3; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. + // + // Always use a hashed value for this ID. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string user_id = 1; + + // The end user's IP address. This field is used to extract location + // information for personalization. + // + // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 + // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This should not be set when: + // + // * setting + // [SearchRequest.user_info][google.cloud.retail.v2beta.SearchRequest.user_info]. + // * using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] + // is set. + string ip_address = 2; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][google.cloud.retail.v2beta.SearchResponse.sponsored_results]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] + // is set. + string user_agent = 3; + + // True if the request is made directly from the end user, in which case the + // [ip_address][google.cloud.retail.v2beta.UserInfo.ip_address] and + // [user_agent][google.cloud.retail.v2beta.UserInfo.user_agent] can be + // populated from the HTTP request. This flag should be set only if the API + // request is made directly from the end user such as a mobile app (and not if + // a gateway or a server is processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent]. + bool direct_user_request = 4; +} + +// The inventory information at a place (e.g. a store) identified +// by a place ID. +message LocalInventory { + // The place ID for the current set of inventory information. + string place_id = 1; + + // Product price and cost information. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 2; + + // Additional local inventory attributes, for example, store name, promotion + // tags, etc. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * At most 30 attributes are allowed. + // * The key must be a UTF-8 encoded string with a length limit of 32 + // characters. + // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, + // key0LikeThis or KEY_1_LIKE_THIS. + // * The attribute values must be of the same type (text or number). + // * Only 1 value is allowed for each attribute. + // * For text values, the length limit is 256 UTF-8 characters. + // * The attribute does not support search. The `searchable` field should be + // unset or set to false. + // * The max summed total bytes of custom attribute keys and values per + // product is 5MiB. + map attributes = 3; + + // Input only. Supported fulfillment types. Valid fulfillment type values + // include commonly used types (such as pickup in store and same day + // delivery), and custom types. Customers have to map custom types to their + // display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string fulfillment_types = 4 + [(google.api.field_behavior) = INPUT_ONLY]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto new file mode 100644 index 00000000..6a1f2907 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto @@ -0,0 +1,199 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Auto-completion service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service CompletionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified prefix with keyword suggestions. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }; + } + + // Bulk import of processed completion dataset. + // + // Request processing is asynchronous. Partial updating is not supported. + // + // The operation is successfully finished only after the imported suggestions + // are indexed successfully and ready for serving. The process takes hours. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc ImportCompletionData(ImportCompletionDataRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ImportCompletionDataResponse" + metadata_type: "google.cloud.retail.v2beta.ImportMetadata" + }; + } +} + +// Auto-complete parameters. +message CompleteQueryRequest { + // Required. Catalog for which the completion is performed. + // + // Full resource name of catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The query used to generate suggestions. + // + // The maximum number of allowed characters is 255. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required field. A unique identifier for tracking visitors. For example, + // this could be implemented with an HTTP cookie, which should be able to + // uniquely identify a visitor on a single device. This unique identifier + // should not change if the visitor logs in or out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 7; + + // The language filters applied to the output suggestions. If set, it should + // contain the language of the query. If not set, suggestions are returned + // without considering language restrictions. This is the BCP-47 language + // code, such as "en-US" or "sr-Latn". For more information, see [Tags for + // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + // number of language codes is 3. + repeated string language_codes = 3; + + // The device type context for completion suggestions. + // It is useful to apply different suggestions on different device types, e.g. + // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + // types. + // + // Supported formats: + // + // * `UNKNOWN_DEVICE_TYPE` + // + // * `DESKTOP` + // + // * `MOBILE` + // + // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + string device_type = 4; + + // Determines which dataset to use for fetching completion. "user-data" will + // use the imported dataset through + // [CompletionService.ImportCompletionData][google.cloud.retail.v2beta.CompletionService.ImportCompletionData]. + // "cloud-retail" will use the dataset generated by cloud retail based on user + // events. If leave empty, it will use the "user-data". + // + // Current supported values: + // + // * user-data + // + // * cloud-retail + // This option requires additional allowlisting. Before using cloud-retail, + // contact Cloud Retail support team first. + string dataset = 6; + + // Completion max suggestions. If left unset or set to 0, then will fallback + // to the configured value + // [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions]. + // + // The maximum allowed max suggestions is 20. If it is set higher, it will be + // capped by 20. + int32 max_suggestions = 5; +} + +// Response of the auto-complete query. +message CompleteQueryResponse { + // Resource that represents completion results. + message CompletionResult { + // The suggestion for the query. + string suggestion = 1; + + // Custom attributes for the suggestion term. + // * For "user-data", the attributes are additional custom attributes + // ingested through BigQuery. + // * For "cloud-retail", the attributes are product attributes generated + // by Cloud Retail. + map attributes = 2; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Results of the matching suggestions. The result list is ordered and the + // first result is top suggestion. + repeated CompletionResult completion_results = 1; + + // A unique complete token. This should be included in the + // [UserEvent.completion_detail][google.cloud.retail.v2beta.UserEvent.completion_detail] + // for search events resulting from this completion, which enables accurate + // attribution of complete model performance. + string attribution_token = 2; + + // Matched recent searches of this user. The maximum number of recent searches + // is 10. This field is a restricted feature. Contact Retail Search support + // team if you are interested in enabling it. + // + // This feature is only available when + // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2beta.CompleteQueryRequest.visitor_id] + // field is set and [UserEvent][google.cloud.retail.v2beta.UserEvent] is + // imported. The recent searches satisfy the follow rules: + // * They are ordered from latest to oldest. + // * They are matched with + // [CompleteQueryRequest.query][google.cloud.retail.v2beta.CompleteQueryRequest.query] + // case insensitively. + // * They are transformed to lower cases. + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto new file mode 100644 index 00000000..e5562227 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto @@ -0,0 +1,84 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configures dynamic serving time metadata that is used to pre and post +// process search/recommendation model results. +message Control { + option (google.api.resource) = { + type: "retail.googleapis.com/Control" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }; + + // The behavior/type of the control + // + // A behavior/type must be specified on creation. Type cannot be changed once + // specified (e.g. A Rule control will always be a Rule control.). An + // INVALID_ARGUMENT will be returned if either condition is violated. + oneof control { + // A facet specification to perform faceted search. + SearchRequest.FacetSpec facet_spec = 3; + + // A rule control - a condition-action pair. + // Enacts a set action when the condition is triggered. + // For example: Boost "gShoe" when query full matches "Running Shoes". + Rule rule = 4; + } + + // Immutable. Fully qualified name + // projects/*/locations/global/catalogs/*/controls/* + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable control display name. Used in Retail UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is thrown. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Output only. List of serving configuration ids that that are associated + // with this control. Note the association is managed via the ServingConfig, + // this is an output only denormalizeed view. Assumed to be in the same + // catalog. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the serving config is used + // for. Currently we support setting only one type of solution at creation + // time. + // + // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. + // If no solution type is provided at creation time, will default to + // SOLUTION_TYPE_SEARCH. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto new file mode 100644 index 00000000..922c46f2 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto @@ -0,0 +1,184 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/control.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for modifying Control. +service ControlService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a Control. + // + // If the [Control][google.cloud.retail.v2beta.Control] to create already + // exists, an ALREADY_EXISTS error is returned. + rpc CreateControl(CreateControlRequest) returns (Control) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" + body: "control" + }; + option (google.api.method_signature) = "parent,control,control_id"; + } + + // Deletes a Control. + // + // If the [Control][google.cloud.retail.v2beta.Control] to delete does not + // exist, a NOT_FOUND error is returned. + rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Control. + // + // [Control][google.cloud.retail.v2beta.Control] cannot be set to a different + // oneof field, if so an INVALID_ARGUMENT is returned. If the + // [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a + // NOT_FOUND error is returned. + rpc UpdateControl(UpdateControlRequest) returns (Control) { + option (google.api.http) = { + patch: "/v2beta/{control.name=projects/*/locations/*/catalogs/*/controls/*}" + body: "control" + }; + option (google.api.method_signature) = "control,update_mask"; + } + + // Gets a Control. + rpc GetControl(GetControlRequest) returns (Control) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all Controls linked to this catalog. + rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request for CreateControl method. +message CreateControlRequest { + // Required. Full resource name of parent catalog. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The Control to create. + Control control = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the Control, which will become the final + // component of the Control's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string control_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateControl method. +message UpdateControlRequest { + // Required. The Control to update. + Control control = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Control][google.cloud.retail.v2beta.Control] to update. The following are + // NOT supported: + // + // * [Control.name][google.cloud.retail.v2beta.Control.name] + // + // If not set or empty, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteControl method. +message DeleteControlRequest { + // Required. The resource name of the Control to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for GetControl method. +message GetControlRequest { + // Required. The resource name of the Control to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for ListControls method. +message ListControlsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 50. Max allowed value is 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListControls` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2beta.ListControlsRequest.filter] is unset. + // * List controls that are used in a single ServingConfig: + // 'serving_config = "boosted_home_page_cvr"' + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListControls method. +message ListControlsResponse { + // All the Controls for a given catalog. + repeated Control controls = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto new file mode 100644 index 00000000..249f5011 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto @@ -0,0 +1,77 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ExportConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configuration of destination for Export related errors. +message ExportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage path for import errors. This must be an empty, + // existing Cloud Storage bucket. Export errors will be written to a file in + // this bucket, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Metadata related to the progress of the Export operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ExportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Response of the ExportProductsRequest. If the long running +// operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ExportErrorsConfig errors_config = 2; +} + +// Response of the ExportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ExportErrorsConfig errors_config = 2; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto new file mode 100644 index 00000000..c1390ab0 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto @@ -0,0 +1,397 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/cloud/retail/v2beta/user_event.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Google Cloud Storage location for input content. +// format. +message GcsSource { + // Required. Google Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. A request can + // contain at most 100 files, and each file can be up to 2 GB. See + // [Importing product + // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) + // for the expected file format and setup instructions. + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2beta.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. + // * `user_event_ga360`: Using + // https://support.google.com/analytics/answer/3437719. + // + // Supported values for control imports: + // + // * 'control' (default): One JSON + // [Control][google.cloud.retail.v2beta.Control] per line. + // + // Supported values for catalog attribute imports: + // + // * 'catalog_attribute' (default): One CSV + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + google.type.Date partition_date = 6; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 5; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 3; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2beta.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. + // * `user_event_ga360`: + // The schema is available here: + // https://support.google.com/analytics/answer/3437719. + // * `user_event_ga4`: This feature is in private preview. Please contact the + // support team for importing Google Analytics 4 events. + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for auto-completion imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + string data_schema = 4; +} + +// The inline source for the input config for ImportProducts method. +message ProductInlineSource { + // Required. A list of products to update/create. Each product must have a + // valid [Product.id][google.cloud.retail.v2beta.Product.id]. Recommended max + // of 100 items. + repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The inline source for the input config for ImportUserEvents method. +message UserEventInlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configuration of destination for Import related errors. +message ImportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors will be written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for Import methods. +message ImportProductsRequest { + // Indicates how imported products are reconciled with the existing products + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new products or updates existing products. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire product dataset. Existing + // products may be deleted if they are not present in the source location. + // + // Can only be set while using + // [BigQuerySource][google.cloud.retail.v2beta.BigQuerySource]. And the + // BigQuery dataset must be created in the data location "us (multiple + // regions in United States)", otherwise a PERMISSION_DENIED error is + // thrown. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + FULL = 2; + } + + // Required. + // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + // + // If no updateMask is specified, requires products.create permission. + // If updateMask is specified, requires products.update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Deprecated. This field has no effect. + string request_id = 6 [deprecated = true]; + + // Required. The desired input location of the data. + ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. + ImportErrorsConfig errors_config = 3; + + // Indicates which fields in the provided imported 'products' to update. If + // not set, will by default update all fields. + google.protobuf.FieldMask update_mask = 4; + + // The mode of reconciliation between existing products and the products to be + // imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 5; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + string notification_pubsub_topic = 7; +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // Required. `projects/1234/locations/global/catalogs/default_catalog` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + UserEventInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorsConfig errors_config = 3; +} + +// Request message for ImportCompletionData methods. +message ImportCompletionDataRequest { + // Required. The catalog which the suggestions dataset belongs to. + // + // Format: `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + CompletionDataInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 3; +} + +// The input config source for products. +message ProductInputConfig { + // Required. The source of the input. + oneof source { + // The Inline source for the input content for products. + ProductInlineSource product_inline_source = 1; + + // Google Cloud Storage location for the input content. + GcsSource gcs_source = 2; + + // BigQuery input source. + BigQuerySource big_query_source = 3; + } +} + +// The input config source for user events. +message UserEventInputConfig { + // The source of the input. + oneof source { + // Required. The Inline source for the input content for UserEvents. + UserEventInlineSource user_event_inline_source = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Google Cloud Storage location for the input content. + GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource big_query_source = 3 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// The input config source for completion data. +message CompletionDataInputConfig { + // The source of the input. + // + // Supported + // [BigQuerySource.data_schema][google.cloud.retail.v2beta.BigQuerySource.data_schema] + // values for suggestions imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + oneof source { + // Required. BigQuery input source. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + BigQuerySource big_query_source = 1 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// Metadata related to the progress of the Import operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ImportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; + + // Deprecated. This field is never set. + string request_id = 5 [deprecated = true]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; +} + +// Response of the +// [ImportProductsRequest][google.cloud.retail.v2beta.ImportProductsRequest]. If +// the long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorsConfig errors_config = 2; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorsConfig errors_config = 2; + + // Aggregated statistics of user event import status. + UserEventImportSummary import_summary = 3; +} + +// A summary of import result. The UserEventImportSummary summarizes +// the import status for user events. +message UserEventImportSummary { + // Count of user events imported with complete existing catalog information. + int64 joined_events_count = 1; + + // Count of user events imported, but with catalog information not found + // in the imported catalog. + int64 unjoined_events_count = 2; +} + +// Response of the +// [ImportCompletionDataRequest][google.cloud.retail.v2beta.ImportCompletionDataRequest]. +// If the long running operation is done, this message is returned by the +// google.longrunning.Operations.response field if the operation is successful. +message ImportCompletionDataResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto new file mode 100644 index 00000000..c5ec1871 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto @@ -0,0 +1,194 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2beta/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "PredictionServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for making recommendation prediction. +service PredictionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation prediction. + rpc Predict(PredictRequest) returns (PredictResponse) { + option (google.api.http) = { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" + body: "*" + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} + // The ID of the Recommendations AI placement. Before you can request + // predictions from your model, you must create at least one placement for it. + // For more information, see [Managing + // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + // + // The full list of available placements can be seen at + // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the predict request. Note that this user event detail + // won't be ingested to userEvent logs. Thus, a separate userEvent write + // request is required for event logging. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return per page. Set this property + // to the number of prediction results needed. If zero, the service will + // choose a reasonable default. The maximum allowed value is 100. Values + // above 100 will be coerced to 100. + int32 page_size = 3; + + // The previous PredictResponse.next_page_token. + string page_token = 4; + + // Filter for restricting prediction results with a length limit of 5,000 + // characters. Accepts values for tags and the `filterOutOfStockItems` flag. + // + // * Tag expressions. Restricts predictions to products that match all of the + // specified tags. Boolean operators `OR` and `NOT` are supported if the + // expression is enclosed in parentheses, and must be separated from the + // tag values by a space. `-"tagA"` is also supported and is equivalent to + // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + // with a size limit of 1,000 characters. + // + // Note: "Recently viewed" models don't support tag filtering at the + // moment. + // + // * filterOutOfStockItems. Restricts predictions to products that do not + // have a + // stockState value of OUT_OF_STOCK. + // + // Examples: + // + // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + // * filterOutOfStockItems tag=(-"promotional") + // * filterOutOfStockItems + // + // If your filter blocks all prediction results, the API will return generic + // (unfiltered) popular products. If you only want results strictly matching + // the filters, set `strictFiltering` to True in `PredictRequest.params` to + // receive empty results instead. + // Note that the API will never return items with storageStatus of "EXPIRED" + // or "DELETED" regardless of filter choices. + string filter = 5; + + // Use validate only mode for this prediction query. If set to true, a + // dummy model will be used that returns arbitrary products. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 6; + + // Additional domain specific parameters for the predictions. + // + // Allowed values: + // + // * `returnProduct`: Boolean. If set to true, the associated product + // object will be returned in the `results.metadata` field in the + // prediction response. + // * `returnScore`: Boolean. If set to true, the prediction 'score' + // corresponding to each returned product will be set in the + // `results.metadata` field in the prediction response. The given + // 'score' indicates the probability of an product being clicked/purchased + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular products instead of empty if + // your filter blocks all prediction results. + // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-price-reranking', 'low-price-reranking', + // 'medium-price-reranking', 'high-price-reranking'}. This gives + // request-level control and adjusts prediction results based on product + // price. + // * `diversityLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-diversity', 'low-diversity', + // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + // request-level control and adjusts prediction results based on product + // category. + map params = 7; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters, and cannot be empty. Values can be empty, and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 8; +} + +// Response message for predict method. +message PredictResponse { + // PredictionResult represents the recommendation prediction results. + message PredictionResult { + // ID of the recommended product + string id = 1; + + // Additional product metadata / annotations. + // + // Possible values: + // + // * `product`: JSON representation of the product. Will be set if + // `returnProduct` is set to true in `PredictRequest.params`. + // * `score`: Prediction score in double value. Will be set if + // `returnScore` is set to true in `PredictRequest.params`. + map metadata = 2; + } + + // A list of recommended products. The order represents the ranking (from the + // most relevant product to the least). + repeated PredictionResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this + // recommendation, which enables accurate attribution of recommendation model + // performance. + string attribution_token = 2; + + // IDs of products in the request that were missing from the inventory. + repeated string missing_ids = 3; + + // True if the validateOnly property was set in the request. + bool validate_only = 4; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto new file mode 100644 index 00000000..4e6dfec8 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto @@ -0,0 +1,566 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/promotion.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" +}; + +// Product captures all metadata information of items to be recommended or +// searched. +message Product { + option (google.api.resource) = { + type: "retail.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }; + + // The type of this product. + enum Type { + // Default value. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] + // if unset. + TYPE_UNSPECIFIED = 0; + + // The primary type. + // + // As the primary unit for predicting, indexing and search serving, a + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] is grouped with multiple + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s. + PRIMARY = 1; + + // The variant type. + // + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s usually share some common + // attributes on the same + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s, but they have variant + // attributes like different colors, sizes and prices, etc. + VARIANT = 2; + + // The collection type. Collection products are bundled + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s or + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s that are sold together, + // such as a jewelry set with necklaces, earrings and rings, etc. + COLLECTION = 3; + } + + // Product availability. If this field is unspecified, the product is + // assumed to be in stock. + enum Availability { + // Default product availability. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK] + // if unset. + AVAILABILITY_UNSPECIFIED = 0; + + // Product in stock. + IN_STOCK = 1; + + // Product out of stock. + OUT_OF_STOCK = 2; + + // Product that is in pre-order state. + PREORDER = 3; + + // Product that is back-ordered (i.e. temporarily out of stock). + BACKORDER = 4; + } + + oneof expiration { + // The timestamp when this product becomes unavailable for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // If it is set, the [Product][google.cloud.retail.v2beta.Product] is not + // available for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // after [expire_time][google.cloud.retail.v2beta.Product.expire_time]. + // However, the product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // [expire_time][google.cloud.retail.v2beta.Product.expire_time] must be + // later than + // [available_time][google.cloud.retail.v2beta.Product.available_time] and + // [publish_time][google.cloud.retail.v2beta.Product.publish_time], + // otherwise an INVALID_ARGUMENT error is thrown. + // + // Corresponding properties: Google Merchant Center property + // [expiration_date](https://support.google.com/merchants/answer/6324499). + google.protobuf.Timestamp expire_time = 16; + + // Input only. The TTL (time to live) of the product. + // + // If it is set, it must be a non-negative value, and + // [expire_time][google.cloud.retail.v2beta.Product.expire_time] is set as + // current timestamp plus [ttl][google.cloud.retail.v2beta.Product.ttl]. The + // derived [expire_time][google.cloud.retail.v2beta.Product.expire_time] is + // returned in the output and [ttl][google.cloud.retail.v2beta.Product.ttl] + // is left blank when retrieving the + // [Product][google.cloud.retail.v2beta.Product]. + // + // If it is set, the product is not available for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // after current timestamp plus + // [ttl][google.cloud.retail.v2beta.Product.ttl]. However, the product can + // still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + google.protobuf.Duration ttl = 17 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Immutable. Full resource name of the product, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. [Product][google.cloud.retail.v2beta.Product] identifier, which + // is the final component of [name][google.cloud.retail.v2beta.Product.name]. + // For example, this field is "id_1", if + // [name][google.cloud.retail.v2beta.Product.name] is + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [id](https://support.google.com/merchants/answer/6324405). Schema.org + // property [Product.sku](https://schema.org/sku). + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The type of the product. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] + // if unset. + Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Variant group identifier. Must be an + // [id][google.cloud.retail.v2beta.Product.id], with the same parent branch + // with this product. Otherwise, an error is thrown. + // + // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s, this field can only be + // empty or set to the same value as + // [id][google.cloud.retail.v2beta.Product.id]. + // + // For VARIANT [Product][google.cloud.retail.v2beta.Product]s, this field + // cannot be empty. A maximum of 2,000 products are allowed to share the same + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [item_group_id](https://support.google.com/merchants/answer/6324507). + // Schema.org property + // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). + string primary_product_id = 4; + + // The [id][google.cloud.retail.v2beta.Product.id] of the collection members + // when [type][google.cloud.retail.v2beta.Product.type] is + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]. + // + // Non-existent product ids are allowed. + // The [type][google.cloud.retail.v2beta.Product.type] of the members must be + // either [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] or + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] otherwise + // and INVALID_ARGUMENT error is thrown. Should not set it for other types. A + // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is + // return. + repeated string collection_member_ids = 5; + + // The Global Trade Item Number (GTIN) of the product. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Corresponding properties: Google Merchant Center property + // [gtin](https://support.google.com/merchants/answer/6324461). + // Schema.org property + // [Product.isbn](https://schema.org/isbn), + // [Product.gtin8](https://schema.org/gtin8), + // [Product.gtin12](https://schema.org/gtin12), + // [Product.gtin13](https://schema.org/gtin13), or + // [Product.gtin14](https://schema.org/gtin14). + // + // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. + string gtin = 6; + + // Product categories. This field is repeated for supporting one product + // belonging to several parallel categories. Strongly recommended using the + // full path for better search / recommendation quality. + // + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // For example, if a shoes product belongs to both + // ["Shoes & Accessories" -> "Shoes"] and + // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be + // represented as: + // + // "categories": [ + // "Shoes & Accessories > Shoes", + // "Sports & Fitness > Athletic Clothing > Shoes" + // ] + // + // Must be set for + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] otherwise an INVALID_ARGUMENT + // error is returned. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [google_product_category][mc_google_product_category]. Schema.org property + // [Product.category] (https://schema.org/category). + // + // [mc_google_product_category]: + // https://support.google.com/merchants/answer/6324436 + repeated string categories = 7; + + // Required. Product title. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [title](https://support.google.com/merchants/answer/6324415). Schema.org + // property [Product.name](https://schema.org/name). + string title = 8 [(google.api.field_behavior) = REQUIRED]; + + // The brands of the product. + // + // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded + // string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [brand](https://support.google.com/merchants/answer/6324351). Schema.org + // property [Product.brand](https://schema.org/brand). + repeated string brands = 9; + + // Product description. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [description](https://support.google.com/merchants/answer/6324468). + // Schema.org property [Product.description](https://schema.org/description). + string description = 10; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // + // For product prediction, this field is ignored and the model automatically + // detects the text language. The + // [Product][google.cloud.retail.v2beta.Product] can include text in different + // languages, but duplicating [Product][google.cloud.retail.v2beta.Product]s + // to provide text in multiple languages can result in degraded model + // performance. + // + // For product search this field is in use. It defaults to "en-US" if unset. + string language_code = 11; + + // Highly encouraged. Extra product attributes to be included. For example, + // for products, this could include the store name, vendor, style, color, etc. + // These are very strong signals for recommendation model, thus we highly + // recommend providing the attributes here. + // + // Features that can take on one of a limited number of possible values. Two + // types of features can be set are: + // + // Textual features. some examples would be the brand/maker of a product, or + // country of a customer. Numerical features. Some examples would be the + // height/weight of a product, or age of a customer. + // + // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, + // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} + // }`. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * Max entries count: 200. + // * The key must be a UTF-8 encoded string with a length limit of 128 + // characters. + // * For indexable attribute, the key must match the pattern: + // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or + // `KEY_1_LIKE_THIS`. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a non-empty UTF-8 encoded string with a + // length limit of 256 characters. + // * For number attributes, at most 400 values are allowed. + map attributes = 12; + + // Custom tags associated with the product. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. This value must be a UTF-8 + // encoded string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This tag can be used for filtering recommendation results by passing the + // tag as part of the + // [PredictRequest.filter][google.cloud.retail.v2beta.PredictRequest.filter]. + // + // Corresponding properties: Google Merchant Center property + // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). + repeated string tags = 13; + + // Product price and cost information. + // + // Corresponding properties: Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 14; + + // The rating of this product. + Rating rating = 15; + + // The timestamp when this [Product][google.cloud.retail.v2beta.Product] + // becomes available for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + google.protobuf.Timestamp available_time = 18; + + // The online availability of the + // [Product][google.cloud.retail.v2beta.Product]. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK]. + // + // Corresponding properties: Google Merchant Center property + // [availability](https://support.google.com/merchants/answer/6324448). + // Schema.org property [Offer.availability](https://schema.org/availability). + Availability availability = 19; + + // The available quantity of the item. + google.protobuf.Int32Value available_quantity = 20; + + // Fulfillment information, such as the store IDs for in-store pickup or + // region IDs for different shipping methods. + // + // All the elements must have distinct + // [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated FulfillmentInfo fulfillment_info = 21; + + // Canonical URL directly linking to the product detail page. + // + // It is strongly recommended to provide a valid uri for the product, + // otherwise the service performance could be significantly degraded. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [link](https://support.google.com/merchants/answer/6324416). Schema.org + // property [Offer.url](https://schema.org/url). + string uri = 22; + + // Product images for the product. We highly recommend putting the main + // image first. + // + // A maximum of 300 images are allowed. + // + // Corresponding properties: Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + repeated Image images = 23; + + // The target group associated with a given audience (e.g. male, veterans, + // car owners, musicians, etc.) of the product. + Audience audience = 24; + + // The color of the product. + // + // Corresponding properties: Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + ColorInfo color_info = 25; + + // The size of the product. To represent different size systems or size types, + // consider using this format: [[[size_system:]size_type:]size_value]. + // + // For example, in "US:MENS:M", "US" represents size system; "MENS" represents + // size type; "M" represents size value. In "GIRLS:27", size system is empty; + // "GIRLS" represents size type; "27" represents size value. In "32 inches", + // both size system and size type are empty, while size value is "32 inches". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [size](https://support.google.com/merchants/answer/6324492), + // [size_type](https://support.google.com/merchants/answer/6324497), and + // [size_system](https://support.google.com/merchants/answer/6324502). + // Schema.org property [Product.size](https://schema.org/size). + repeated string sizes = 26; + + // The material of the product. For example, "leather", "wooden". + // + // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 200 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [material](https://support.google.com/merchants/answer/6324410). Schema.org + // property [Product.material](https://schema.org/material). + repeated string materials = 27; + + // The pattern or graphic print of the product. For example, "striped", "polka + // dot", "paisley". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org + // property [Product.pattern](https://schema.org/pattern). + repeated string patterns = 28; + + // The condition of the product. Strongly encouraged to use the standard + // values: "new", "refurbished", "used". + // + // A maximum of 1 value is allowed per + // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [condition](https://support.google.com/merchants/answer/6324469). + // Schema.org property + // [Offer.itemCondition](https://schema.org/itemCondition). + repeated string conditions = 29; + + // The promotions applied to the product. A maximum of 10 values are allowed + // per [Product][google.cloud.retail.v2beta.Product]. Only + // [Promotion.promotion_id][google.cloud.retail.v2beta.Promotion.promotion_id] + // will be used, other fields will be ignored if set. + repeated Promotion promotions = 34; + + // The timestamp when the product is published by the retailer for the first + // time, which indicates the freshness of the products. Note that this field + // is different from + // [available_time][google.cloud.retail.v2beta.Product.available_time], given + // it purely describes product freshness regardless of when it is available on + // search and recommendation. + google.protobuf.Timestamp publish_time = 33; + + // Indicates which fields in the + // [Product][google.cloud.retail.v2beta.Product]s are returned in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse]. + // + // Supported fields for all [type][google.cloud.retail.v2beta.Product.type]s: + // + // * [audience][google.cloud.retail.v2beta.Product.audience] + // * [availability][google.cloud.retail.v2beta.Product.availability] + // * [brands][google.cloud.retail.v2beta.Product.brands] + // * [color_info][google.cloud.retail.v2beta.Product.color_info] + // * [conditions][google.cloud.retail.v2beta.Product.conditions] + // * [gtin][google.cloud.retail.v2beta.Product.gtin] + // * [materials][google.cloud.retail.v2beta.Product.materials] + // * [name][google.cloud.retail.v2beta.Product.name] + // * [patterns][google.cloud.retail.v2beta.Product.patterns] + // * [price_info][google.cloud.retail.v2beta.Product.price_info] + // * [rating][google.cloud.retail.v2beta.Product.rating] + // * [sizes][google.cloud.retail.v2beta.Product.sizes] + // * [title][google.cloud.retail.v2beta.Product.title] + // * [uri][google.cloud.retail.v2beta.Product.uri] + // + // Supported fields only for + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]: + // + // * [categories][google.cloud.retail.v2beta.Product.categories] + // * [description][google.cloud.retail.v2beta.Product.description] + // * [images][google.cloud.retail.v2beta.Product.images] + // + // Supported fields only for + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]: + // + // * Only the first image in + // [images][google.cloud.retail.v2beta.Product.images] + // + // To mark [attributes][google.cloud.retail.v2beta.Product.attributes] as + // retrievable, include paths of the form "attributes.key" where "key" is the + // key of a custom attribute, as specified in + // [attributes][google.cloud.retail.v2beta.Product.attributes]. + // + // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], the + // following fields are always returned in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] by default: + // + // * [name][google.cloud.retail.v2beta.Product.name] + // + // For [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT], the + // following fields are always returned in by default: + // + // * [name][google.cloud.retail.v2beta.Product.name] + // * [color_info][google.cloud.retail.v2beta.Product.color_info] + // + // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] may increase + // response payload size and serving latency. + google.protobuf.FieldMask retrievable_fields = 30; + + // Output only. Product variants grouped together on primary product which + // share similar product attributes. It's automatically grouped by + // [primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] + // for all the product variants. Only populated for + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. + // Do not set this field in API requests. + repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto new file mode 100644 index 00000000..0ad73436 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto @@ -0,0 +1,829 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for ingesting [Product][google.cloud.retail.v2beta.Product] +// information of the customer's website. +service ProductService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Product][google.cloud.retail.v2beta.Product]. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Gets a [Product][google.cloud.retail.v2beta.Product]. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Product][google.cloud.retail.v2beta.Product]s. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a [Product][google.cloud.retail.v2beta.Product]. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v2beta/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Deletes a [Product][google.cloud.retail.v2beta.Product]. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. + // + // Request processing may be synchronous. No partial updating is supported. + // Non-existing items are created. + // + // Note that it is possible for a subset of the + // [Product][google.cloud.retail.v2beta.Product]s to be successfully updated. + rpc ImportProducts(ImportProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ImportProductsResponse" + metadata_type: "google.cloud.retail.v2beta.ImportMetadata" + }; + } + + // Updates inventory information for a + // [Product][google.cloud.retail.v2beta.Product] while respecting the last + // update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, updates are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // When inventory is updated with + // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], + // the specified inventory field value(s) will overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update time for the specified inventory fields will be overwritten to the + // time of the + // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or + // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // request. + // + // If no inventory fields are set in + // [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], + // then any pre-existing inventory information for this product will be used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], + // then any existing inventory information will be preserved. + // + // Pre-existing inventory information can only be updated with + // [SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], + // [AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], + // and + // [RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" + body: "*" + }; + option (google.api.method_signature) = "inventory,set_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.SetInventoryResponse" + metadata_type: "google.cloud.retail.v2beta.SetInventoryMetadata" + }; + } + + // Incrementally adds place IDs to + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the added place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata" + }; + } + + // Incrementally removes place IDs from a + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the removed place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata" + }; + } + + // Updates local inventory information for a + // [Product][google.cloud.retail.v2beta.Product] at a list of places, while + // respecting the last update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // inventory information. If the request is valid, the update will be enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddLocalInventories(AddLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.AddLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2beta.AddLocalInventoriesMetadata" + }; + } + + // Remove local inventory information for a + // [Product][google.cloud.retail.v2beta.Product] at a list of places at a + // removal timestamp. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, removals are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or + // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata" + }; + } +} + +// Request message for [CreateProduct][] method. +message CreateProductRequest { + // Required. The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The [Product][google.cloud.retail.v2beta.Product] to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Product][google.cloud.retail.v2beta.Product], which will become the final + // component of the [Product.name][google.cloud.retail.v2beta.Product.name]. + // + // If the caller does not have permission to create the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // This field must be unique among all + // [Product][google.cloud.retail.v2beta.Product]s with the same + // [parent][google.cloud.retail.v2beta.CreateProductRequest.parent]. + // Otherwise, an ALREADY_EXISTS error is returned. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string product_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [GetProduct][] method. +message GetProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the requested [Product][google.cloud.retail.v2beta.Product] does not + // exist, a NOT_FOUND error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for [UpdateProduct][] method. +message UpdateProductRequest { + // Required. The product to update/create. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2beta.Product] to update does not + // exist and + // [allow_missing][google.cloud.retail.v2beta.UpdateProductRequest.allow_missing] + // is not set, a NOT_FOUND error is returned. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Product][google.cloud.retail.v2beta.Product] to update. The immutable and + // output only fields are NOT supported. If not set, all supported fields (the + // fields that are neither immutable nor output only) are updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, a new [Product][google.cloud.retail.v2beta.Product] will be + // created. In this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for [DeleteProduct][] method. +message DeleteProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to delete the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2beta.Product] to delete does not + // exist, a NOT_FOUND error is returned. + // + // The [Product][google.cloud.retail.v2beta.Product] to delete can neither be + // a + // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2beta.Product] member nor a + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] with more than one + // [variants][google.cloud.retail.v2beta.Product.Type.VARIANT]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // All inventory information for the named + // [Product][google.cloud.retail.v2beta.Product] will be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] +// method. +message ListProductsRequest { + // Required. The parent branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use + // `default_branch` as the branch ID, to list products under the default + // branch. + // + // If the caller does not have permission to list + // [Product][google.cloud.retail.v2beta.Product]s under this branch, + // regardless of whether or not this branch exists, a PERMISSION_DENIED error + // is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. + // If unspecified, defaults to 100. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT error is returned. + int32 page_size = 2; + + // A page token + // [ListProductsResponse.next_page_token][google.cloud.retail.v2beta.ListProductsResponse.next_page_token], + // received from a previous + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; + + // A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2beta.ListProductsRequest.filter] is unset. + // * List + // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s sharing the same + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]. For example: + // `primary_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2beta.Product]s bundled in a + // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2beta.Product]. + // For example: + // `collection_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2beta.Product]s with a partibular + // type. For example: + // `type = "PRIMARY"` + // `type = "VARIANT"` + // `type = "COLLECTION"` + // + // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + // + // If the specified + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] or + // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2beta.Product] does not exist, a NOT_FOUND + // error is returned. + string filter = 4; + + // The fields of [Product][google.cloud.retail.v2beta.Product] to return in + // the responses. If not set or empty, the following fields are returned: + // + // * [Product.name][google.cloud.retail.v2beta.Product.name] + // * [Product.id][google.cloud.retail.v2beta.Product.id] + // * [Product.title][google.cloud.retail.v2beta.Product.title] + // * [Product.uri][google.cloud.retail.v2beta.Product.uri] + // * [Product.images][google.cloud.retail.v2beta.Product.images] + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // * [Product.brands][google.cloud.retail.v2beta.Product.brands] + // + // If "*" is provided, all fields are returned. + // [Product.name][google.cloud.retail.v2beta.Product.name] is always returned + // no matter what mask is set. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask read_mask = 5; +} + +// Response message for +// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] +// method. +message ListProductsResponse { + // The [Product][google.cloud.retail.v2beta.Product]s. + repeated Product products = 1; + + // A token that can be sent as + // [ListProductsRequest.page_token][google.cloud.retail.v2beta.ListProductsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for [SetInventory][] method. +message SetInventoryRequest { + // Required. The inventory information to update. The allowable fields to + // update are: + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // * [Product.availability][google.cloud.retail.v2beta.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] + // The updated inventory fields must be specified in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask]. + // + // If [SetInventoryRequest.inventory.name][] is empty or invalid, an + // INVALID_ARGUMENT error is returned. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2beta.Product] named in + // [Product.name][google.cloud.retail.v2beta.Product.name], regardless of + // whether or not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2beta.Product] to update does not + // have existing inventory information, the provided inventory information + // will be inserted. + // + // If the [Product][google.cloud.retail.v2beta.Product] to update has existing + // inventory information, the provided inventory information will be merged + // while respecting the last update time for each inventory field, using the + // provided or default value for + // [SetInventoryRequest.set_time][google.cloud.retail.v2beta.SetInventoryRequest.set_time]. + // + // The caller can replace place IDs for a subset of fulfillment types in the + // following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types and corresponding place IDs + // to update in [SetInventoryRequest.inventory.fulfillment_info][] + // + // The caller can clear all place IDs from a subset of fulfillment types in + // the following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types to clear in + // [SetInventoryRequest.inventory.fulfillment_info][] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] + // + // The last update time is recorded for the following inventory fields: + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // * [Product.availability][google.cloud.retail.v2beta.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] + // + // If a full overwrite of inventory information while ignoring timestamps is + // needed, [UpdateProduct][] should be invoked instead. + Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided + // [Product][google.cloud.retail.v2beta.Product] to update. + // + // At least one field must be provided. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask set_mask = 2; + + // The time when the request is issued, used to prevent + // out-of-order updates on inventory fields with the last update time + // recorded. If not provided, the internal system time will be used. + google.protobuf.Timestamp set_time = 3; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] with + // name [Product.name][google.cloud.retail.v2beta.Product.name] is not found, + // the inventory update will still be processed and retained for at most 1 day + // until the [Product][google.cloud.retail.v2beta.Product] is created. If set + // to false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 4; +} + +// Metadata related to the progress of the SetInventory operation. +// Currently empty because there is no meaningful metadata populated from the +// [SetInventory][] method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the [SetInventory][] +// method. +message SetInventoryResponse {} + +// Request message for [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type], such + // as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery" to be added for this + // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type]. + // Duplicate IDs will be automatically ignored. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // If the total number of place IDs exceeds 2000 for this + // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type] after + // adding, then the update will be rejected. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the AddFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddFulfillmentPlaces][] method. +message AddFulfillmentPlacesMetadata {} + +// Response of the AddFulfillmentPlacesRequest. Currently empty because +// there is no meaningful response populated from the [AddFulfillmentPlaces][] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for [AddLocalInventories][] method. +message AddLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of inventory information at difference places. Each place + // is identified by its place ID. At most 3000 inventories are allowed per + // request. + repeated LocalInventory local_inventories = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided list of + // [LocalInventory][google.cloud.retail.v2beta.LocalInventory] to update. The + // field is updated to the provided value. + // + // If a field is set while the place does not have a previous local inventory, + // the local inventory at that store is created. + // + // If a field is set while the value of that field is not provided, the + // original field value, if it exists, is deleted. + // + // If the mask is not set or set with empty paths, all inventory fields will + // be updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask add_mask = 4; + + // The time when the inventory updates are issued. Used to prevent + // out-of-order updates on local inventory fields. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the local inventory will still be processed and retained for at + // most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 6; +} + +// Metadata related to the progress of the AddLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [AddLocalInventories][] method. +message AddLocalInventoriesMetadata {} + +// Response of the [AddLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [AddLocalInventories][] +// method. +message AddLocalInventoriesResponse {} + +// Request message for [RemoveLocalInventories][] method. +message RemoveLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of place IDs to have their inventory deleted. + // At most 3000 place IDs are allowed per request. + repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; + + // The time when the inventory deletions are issued. Used to prevent + // out-of-order updates and deletions on local inventory fields. If not + // provided, the internal system time will be used. + google.protobuf.Timestamp remove_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the local inventory removal request will still be processed and + // retained for at most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 3; +} + +// Metadata related to the progress of the RemoveLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveLocalInventories][] method. +message RemoveLocalInventoriesMetadata {} + +// Response of the [RemoveLocalInventories][] API. Currently empty because +// there is no meaningful response populated from the [RemoveLocalInventories][] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to [Product.fulfillment_info.type][]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type], + // such as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery", to be removed for this + // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type]. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp remove_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the RemoveFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [RemoveFulfillmentPlaces][] method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the [RemoveFulfillmentPlaces][] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto new file mode 100644 index 00000000..5346f14d --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto @@ -0,0 +1,40 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "PromotionProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Promotion information. +message Promotion { + // ID of the promotion. For example, "free gift". + // + // The value must be a UTF-8 encoded string with a length limit of 128 + // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, + // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Google Merchant Center property + // [promotion](https://support.google.com/merchants/answer/7050148). + string promotion_id = 1; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto new file mode 100644 index 00000000..5ab09aa3 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto @@ -0,0 +1,80 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Metadata related to the progress of the Purge operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeMetadata {} + +// Request message for PurgeUserEvents method. +message PurgeUserEventsRequest { + // Required. The resource name of the catalog under which the events are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The filter string to specify the events to be deleted with a + // length limit of 5,000 characters. Empty string filter is not allowed. The + // eligible fields for filtering are: + // + // * `eventType`: Double quoted + // [UserEvent.event_type][google.cloud.retail.v2beta.UserEvent.event_type] + // string. + // * `eventTime`: in ISO 8601 "zulu" format. + // * `visitorId`: Double quoted string. Specifying this will delete all + // events associated with a visitor. + // * `userId`: Double quoted string. Specifying this will delete all events + // associated with a user. + // + // Examples: + // + // * Deleting all events in a time range: + // `eventTime > "2012-04-23T18:25:43.511Z" + // eventTime < "2012-04-23T18:30:43.511Z"` + // * Deleting specific eventType in time range: + // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + // * Deleting all events for a specific visitor: + // `visitorId = "visitor1024"` + // + // The filtering fields are assumed to have an implicit AND. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any user events. + bool force = 3; +} + +// Response of the PurgeUserEventsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeUserEventsResponse { + // The total count of events purged as a result of the operation. + int64 purged_events_count = 1; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto new file mode 100644 index 00000000..b8b2156a --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto @@ -0,0 +1,791 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service SearchService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" + body: "*" + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] +// method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Product][google.cloud.retail.v2beta.Product] object, over which the + // facet values are computed. Facet key is case-sensitive. + // + // Allowed facet keys when + // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] + // is not specified: + // + // * textual_field = + // * "brands" + // * "categories" + // * "genders" + // * "ageGroups" + // * "availability" + // * "colorFamilies" + // * "colors" + // * "sizes" + // * "materials" + // * "patterns" + // * "conditions" + // * "attributes.key" + // * "pickupInStore" + // * "shipToStore" + // * "sameDayDelivery" + // * "nextDayDelivery" + // * "customFulfillment1" + // * "customFulfillment2" + // * "customFulfillment3" + // * "customFulfillment4" + // * "customFulfillment5" + // * "inventory(place_id,attributes.key)" + // + // * numerical_field = + // * "price" + // * "discount" + // * "rating" + // * "ratingCount" + // * "attributes.key" + // * "inventory(place_id,price)" + // * "inventory(place_id,original_price)" + // * "inventory(place_id,attributes.key)" + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. For example, when using + // "pickupInStore" as key and set restricted values to + // ["store123", "store456"], only facets for "store123" and "store456" are + // returned. Only supported on textual fields and fulfillments. + // Maximum is 20. + // + // Must be set for the fulfillment facet keys: + // + // * pickupInStore + // + // * shipToStore + // + // * sameDayDelivery + // + // * nextDayDelivery + // + // * customFulfillment1 + // + // * customFulfillment2 + // + // * customFulfillment3 + // + // * customFulfillment4 + // + // * customFulfillment5 + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the + // "categories" facet will give only "Women > Shoe" and "Women > Dress". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 8; + + // Only get facet values that contains the given strings. For example, + // suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the + // "categories" facet will give only "Women > Shoe" and "Men > Shoe". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 9; + + // The order in which [Facet.values][] are returned. + // + // Allowed values are: + // + // * "count desc", which means order by [Facet.FacetValue.count][] + // descending. + // + // * "value desc", which means order by [Facet.FacetValue.value][] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.intervals]; + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // are sorted in the order given by + // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.restricted_values]. + string order_by = 4; + + // The query that is used to compute facet for the given facet key. + // When provided, it will override the default behavior of facet + // computation. The query syntax is the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for detail syntax and limitations. Notice that there is no limitation + // on + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // when query is specified. + // + // In the response, [FacetValue.value][] will be always "1" and + // [FacetValue.count][] will be the number of results that matches the + // query. + // + // For example, you can set a customized facet for "shipToStore", + // where + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // is "customizedShipToStore", and + // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] + // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". + // Then the facet will count the products that are both in stock and ship + // to store "123". + string query = 5; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // By default, + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // For example, suppose there are 100 products with color facet "Red" and + // 200 products with color facet "Blue". A query containing the filter + // "colorFamilies:ANY("Red")" and have "colorFamilies" as + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // will by default return the "Red" with count 100. + // + // If this field contains "colorFamilies", then the query returns both the + // "Red" with count 100 and "Blue" with count 200, because the + // "colorFamilies" key is now excluded from the filter. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined by Google + // Retail Search. It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined by + // Google Retail Search. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how Google Retail Search orders "gender" and + // "rating" facets. However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // The specifications of dynamically generated facets. + message DynamicFacetSpec { + // Enum to control DynamicFacet mode + enum Mode { + // Default value. + MODE_UNSPECIFIED = 0; + + // Disable Dynamic Facet. + DISABLED = 1; + + // Automatic mode built by Google Retail Search. + ENABLED = 2; + } + + // Mode of the DynamicFacet feature. + // Defaults to + // [Mode.DISABLED][google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode.DISABLED] + // if it's unset. + Mode mode = 1; + } + + // Boost specification to boost certain items. + message BoostSpec { + // Boost applies to products which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue": + // * (id: ANY("product_1", "product_2")) AND (colorFamilies: + // ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a product matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 10. + repeated ConditionBoostSpec condition_boost_specs = 1; + + // Whether to skip boostspec validation. If this field is set to true, + // invalid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // will be ignored and valid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // will still be applied. + optional bool skip_boost_spec_validation = 2; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. This defaults to + // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.retail.v2beta.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by Google Retail Search. + AUTO = 3; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + + // Whether to pin unexpanded results. If this field is set to true, + // unexpanded products are always at the top of the search results, followed + // by the expanded results. + bool pin_unexpanded_results = 2; + } + + // The specification for personalization. + message PersonalizationSpec { + // The personalization mode of each search request. + enum Mode { + // Default value. Defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The search mode of each search request. + enum SearchMode { + // Default value. In this case both product search and faceted search will + // be performed. Both [SearchResponse.SearchResult] and + // [SearchResponse.Facet] will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only [SearchResponse.SearchResult] will be returned. + // [SearchResponse.Facet] will not be returned, even if + // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] + // or + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] + // is set. + PRODUCT_SEARCH_ONLY = 1; + + // Only faceted search will be performed. The product search will be + // disabled. + // + // When in this mode, one or both of [SearchRequest.facet_spec][] and + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] + // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only + // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the search engine placement, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` + // This field is used to identify the serving configuration name and the set + // of models that will be used to make the search. + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. + // + // Use "default_branch" as the branch ID or leave this field empty, to search + // products under the default branch. + string branch = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Raw search query. + string query = 3; + + // Required. A unique identifier for tracking visitors. For example, this + // could be implemented with an HTTP cookie, which should be able to uniquely + // identify a visitor on a single device. This unique identifier should not + // change if the visitor logs in or out of the website. + // + // This should be the same identifier as + // [UserEvent.visitor_id][google.cloud.retail.v2beta.UserEvent.visitor_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; + + // User information. + UserInfo user_info = 5; + + // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. + // If unspecified, defaults to a reasonable value. The maximum allowed value + // is 120. Values above 120 will be coerced to 120. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 7; + + // A page token + // [SearchResponse.next_page_token][google.cloud.retail.v2beta.SearchResponse.next_page_token], + // received from a previous + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 8; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the [Product][google.cloud.retail.v2beta.Product]s + // deemed by the API as relevant) in search results. This field is only + // considered if + // [page_token][google.cloud.retail.v2beta.SearchRequest.page_token] is unset. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 offset = 9; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. Filter + // expression is case-sensitive. See more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string filter = 10; + + // The default filter that is applied when a user performs a search without + // checking any filters on the search page. + // + // The filter applied to every search request when quality improvement such as + // query expansion is needed. For example, if a query does not have enough + // results, an expanded query with + // [SearchRequest.canonical_filter][google.cloud.retail.v2beta.SearchRequest.canonical_filter] + // will be returned as a supplement of the original query. This field is + // strongly recommended to achieve high search quality. + // + // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for more details about filter syntax. + string canonical_filter = 28; + + // The order in which products are returned. Products can be ordered by + // a field in an [Product][google.cloud.retail.v2beta.Product] object. Leave + // it unset if ordered by relevance. OrderBy expression is case-sensitive. See + // more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#order). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string order_by = 11; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated FacetSpec facet_specs = 12; + + // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + // to enable dynamic facets. Do not set this field. + // + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; + + // Boost specification to boost certain products. See more details at this + // [user guide](https://cloud.google.com/retail/docs/boosting). + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] + // and [SearchRequest.boost_spec] are set, the boost conditions from both + // places are evaluated. If a search request matches multiple boost + // conditions, the final boost score is equal to the sum of the boost scores + // from all matched boost conditions. + BoostSpec boost_spec = 13; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + QueryExpansionSpec query_expansion_spec = 14; + + // The keys to fetch and rollup the matching + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s attributes, + // [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo] or + // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s attributes. + // The attributes from all the matching + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s or + // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s are merged and + // de-duplicated. Notice that rollup attributes will lead to extra query + // latency. Maximum number of keys is 30. + // + // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], a + // fulfillment type and a fulfillment ID must be provided in the format of + // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + // "pickupInStore" is fulfillment type and "store123" is the store ID. + // + // Supported keys are: + // + // * colorFamilies + // * price + // * originalPrice + // * discount + // * variantId + // * inventory(place_id,price) + // * inventory(place_id,original_price) + // * inventory(place_id,attributes.key), where key is any key in the + // [Product.inventories.attributes][] map. + // * attributes.key, where key is any key in the + // [Product.attributes][google.cloud.retail.v2beta.Product.attributes] map. + // * pickupInStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "pickup-in-store". + // * shipToStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "ship-to-store". + // * sameDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "same-day-delivery". + // * nextDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "next-day-delivery". + // * customFulfillment1.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-1". + // * customFulfillment2.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-2". + // * customFulfillment3.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-3". + // * customFulfillment4.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-4". + // * customFulfillment5.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-5". + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + repeated string variant_rollup_keys = 17; + + // The categories associated with a category page. Required for category + // navigation queries to achieve good search quality. The format should be + // the same as + // [UserEvent.page_categories][google.cloud.retail.v2beta.UserEvent.page_categories]; + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + repeated string page_categories = 23; + + // The search mode of the search request. If not specified, a single search + // request triggers both product search and faceted search. + SearchMode search_mode = 31; + + // The specification for personalization. + PersonalizationSpec personalization_spec = 32; +} + +// Response message for +// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] +// method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Product.id][google.cloud.retail.v2beta.Product.id] of the searched + // [Product][google.cloud.retail.v2beta.Product]. + string id = 1; + + // The product data snippet in the search response. Only + // [Product.name][google.cloud.retail.v2beta.Product.name] is guaranteed to + // be populated. + // + // [Product.variants][google.cloud.retail.v2beta.Product.variants] contains + // the product variants that match the search query. If there are multiple + // product variants matching the query, top 5 most relevant product variants + // are returned and ordered by relevancy. + // + // If relevancy can be deternmined, use + // [matching_variant_fields][google.cloud.retail.v2beta.SearchResponse.SearchResult.matching_variant_fields] + // to look up matched product variants fields. If relevancy cannot be + // determined, e.g. when searching "shoe" all products in a shoe product can + // be a match, 5 product variants are returned but order is meaningless. + Product product = 2; + + // The count of matched + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s. + int32 matching_variant_count = 3; + + // If a [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] matches the search query, + // this map indicates which [Product][google.cloud.retail.v2beta.Product] + // fields are matched. The key is the + // [Product.name][google.cloud.retail.v2beta.Product.name], the value is a + // field mask of the matched [Product][google.cloud.retail.v2beta.Product] + // fields. If matched attributes cannot be determined, this map will be + // empty. + // + // For example, a key "sku1" with field mask + // "products.color_info" indicates there is a match between + // "sku1" [ColorInfo][google.cloud.retail.v2beta.ColorInfo] and the query. + map matching_variant_fields = 4; + + // The rollup matching + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] attributes. The key is one + // of the + // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2beta.SearchRequest.variant_rollup_keys]. + // The values are the merged and de-duplicated + // [Product][google.cloud.retail.v2beta.Product] attributes. Notice that the + // rollup values are respect filter. For example, when filtering by + // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is + // returned. + // + // For textual and numerical attributes, the rollup values is a list of + // string or double values with type + // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if + // there are two variants with colors "red" and "blue", the rollup values + // are + // + // { key: "colorFamilies" + // value { + // list_value { + // values { string_value: "red" } + // values { string_value: "blue" } + // } + // } + // } + // + // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], the + // rollup values is a double value with type + // [google.protobuf.Value][google.protobuf.Value]. For example, + // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there + // are 10 variants in this product are available in the store "store1". + map variant_rollup_values = 5; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colorFamilies". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + } + + // The key for this facet. E.g., "colorFamilies" or "price" or + // "attributes.attr1". + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Information describing query expansion including whether expansion has + // occurred. + message QueryExpansionInfo { + // Bool describing whether query expansion has occurred. + bool expanded_query = 1; + + // Number of pinned results. This field will only be set when expansion + // happens and + // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] + // is set to true. + int64 pinned_result_count = 2; + } + + // A list of matched items. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.retail.v2beta.SearchResponse.results] + // returned by pagination may be less than the + // [total_size][google.cloud.retail.v2beta.SearchResponse.total_size] that + // matches. + int32 total_size = 3; + + // If spell correction applies, the corrected query. Otherwise, empty. + string corrected_query = 4; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this + // search, which enables accurate attribution of search model performance. + string attribution_token = 5; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.retail.v2beta.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 6; + + // Query expansion information for the returned results. + QueryExpansionInfo query_expansion_info = 7; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search will be performed, and only + // [redirect_uri][google.cloud.retail.v2beta.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] + // will be set in the response. + string redirect_uri = 10; + + // The fully qualified resource name of applied + // [controls](https://cloud.google.com/retail/docs/serving-control-rules). + repeated string applied_controls = 12; + + // The invalid + // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto new file mode 100644 index 00000000..20112e61 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto @@ -0,0 +1,247 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configures metadata that is used to generate serving time results (e.g. +// search results or recommendation predictions). +// The ServingConfig is passed in the search and predict request and together +// with the Catalog.default_branch, generates results. +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // Immutable. Fully qualified name + // projects/*/locations/global/catalogs/*/servingConfig/* + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable serving config display name. Used in Retail + // UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // The id of the model to use at serving time. + // Currently only RecommendationModels are supported: + // https://cloud.google.com/retail/recommendations-ai/docs/create-models + // Can be changed but only to a compatible model (e.g. + // others-you-may-like CTR to others-you-may-like CVR). + // + // Required when + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string model_id = 3; + + // How much price ranking we want in serving results. + // Price reranking causes product items with a similar + // recommendation probability to be ordered by price, with the + // highest-priced items first. This setting could result in a decrease in + // click-through and conversion rates. + // Allowed values are: + // + // * 'no-price-reranking' + // * 'low-price-raranking' + // * 'medium-price-reranking' + // * 'high-price-reranking' + // + // If not specified, we choose default based on model type. Default value: + // 'no-price-reranking'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string price_reranking_level = 4; + + // Facet specifications for faceted search. If empty, no facets are returned. + // The ids refer to the ids of [Control][google.cloud.retail.v2beta.Control] + // resources with only the Facet control set. These controls are assumed to be + // in the same [Catalog][google.cloud.retail.v2beta.Catalog] as the + // [ServingConfig][google.cloud.retail.v2beta.ServingConfig]. + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string facet_control_ids = 5; + + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; + + // Condition boost specifications. If a product matches multiple conditions + // in the specifications, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 100. + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] + // and [SearchRequest.boost_spec] are set, the boost conditions from both + // places are evaluated. If a search request matches multiple boost + // conditions, the final boost score is equal to the sum of the boost scores + // from all matched boost conditions. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string boost_control_ids = 7; + + // Condition filter specifications. If a product matches multiple conditions + // in the specifications, filters from these specifications are all + // applied and combined via the AND operator. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string filter_control_ids = 9; + + // Condition redirect specifications. Only the first triggered redirect action + // is applied, even if multiple apply. Maximum number of specifications is + // 1000. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string redirect_control_ids = 10; + + // Condition synonyms specifications. If multiple syonyms conditions match, + // all matching synonyms control in the list will execute. Order of controls + // in the list will not matter. Maximum number of specifications is + // 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string twoway_synonyms_control_ids = 18; + + // Condition oneway synonyms specifications. If multiple oneway synonyms + // conditions match, all matching oneway synonyms controls in the list will + // execute. Order of controls in the list will not matter. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string oneway_synonyms_control_ids = 12; + + // Condition do not associate specifications. If multiple do not associate + // conditions match, all matching do not associate controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string do_not_associate_control_ids = 13; + + // Condition replacement specifications. + // - Applied according to the order in the list. + // - A previously replaced term can not be re-replaced. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string replacement_control_ids = 14; + + // Condition ignore specifications. If multiple ignore + // conditions match, all matching ignore controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string ignore_control_ids = 15; + + // How much diversity to use in recommendation model results e.g. + // 'medium-diversity' or 'high-diversity'. Currently supported values: + // + // * 'no-diversity' + // * 'low-diversity' + // * 'medium-diversity' + // * 'high-diversity' + // * 'auto-diversity' + // + // If not specified, we choose default based on recommendation model + // type. Default value: 'no-diversity'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string diversity_level = 8; + + // Whether to add additional category filters on the 'similar-items' model. + // If not specified, we enable it by default. + // Allowed values are: + // + // * 'no-category-match': No additional filtering of original results from + // the model and the customer's filters. + // * 'relaxed-category-match': Only keep results with categories that match + // at least one item categories in the PredictRequests's context item. + // * If customer also sends filters in the PredictRequest, then the results + // will satisfy both conditions (user given and category match). + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string enable_category_filter_level = 16; + + // Required. Immutable. Specifies the solution types that a serving config can + // be associated with. Currently we support setting only one type of solution. + repeated SolutionType solution_types = 19 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto new file mode 100644 index 00000000..e56c28ac --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto @@ -0,0 +1,240 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/serving_config.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for modifying ServingConfig. +service ServingConfigService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a ServingConfig. + // + // A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s + // are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise + // a FAILED_PRECONDITION error is returned. + rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + body: "serving_config" + }; + option (google.api.method_signature) = + "parent,serving_config,serving_config_id"; + } + + // Deletes a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc DeleteServingConfig(DeleteServingConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a ServingConfig. + rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + patch: "/v2beta/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + body: "serving_config" + }; + option (google.api.method_signature) = "serving_config,update_mask"; + } + + // Gets a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all ServingConfigs linked to this catalog. + rpc ListServingConfigs(ListServingConfigsRequest) + returns (ListServingConfigsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Enables a Control on the specified ServingConfig. + // The control is added in the last position of the list of controls + // it belongs to (e.g. if it's a facet spec control it will be applied + // in the last position of servingConfig.facetSpecIds) + // Returns a ALREADY_EXISTS error if the control has already been applied. + // Returns a FAILED_PRECONDITION error if the addition could exceed maximum + // number of control allowed for that type of control. + rpc AddControl(AddControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } + + // Disables a Control on the specified ServingConfig. + // The control is removed from the ServingConfig. + // Returns a NOT_FOUND error if the Control is not enabled for the + // ServingConfig. + rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } +} + +// Request for CreateServingConfig method. +message CreateServingConfigRequest { + // Required. Full resource name of parent. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The ServingConfig to create. + ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the ServingConfig, which will become the final + // component of the ServingConfig's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateServingConfig method. +message UpdateServingConfigRequest { + // Required. The ServingConfig to update. + ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [ServingConfig][google.cloud.retail.v2beta.ServingConfig] to update. The + // following are NOT supported: + // + // * [ServingConfig.name][google.cloud.retail.v2beta.ServingConfig.name] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteServingConfig method. +message DeleteServingConfigRequest { + // Required. The resource name of the ServingConfig to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for GetServingConfig method. +message GetServingConfigRequest { + // Required. The resource name of the ServingConfig to get. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for ListServingConfigs method. +message ListServingConfigsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 100. If a value greater than 100 is provided, at most 100 results are + // returned. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListServingConfigs` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListServingConfigs method. +message ListServingConfigsResponse { + // All the ServingConfigs for a given catalog. + repeated ServingConfig serving_configs = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request for AddControl method. +message AddControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config - if id is not found a NOT_FOUND error is returned. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for RemoveControl method. +message RemoveControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto new file mode 100644 index 00000000..e2175801 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto @@ -0,0 +1,342 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// UserEvent captures all metadata information Retail API needs to know about +// how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // * `add-to-cart`: Products being added to cart. + // * `category-page-view`: Special pages such as sale or promotion pages + // viewed. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed. + // * `promotion-offered`: Promotion is offered to a user. + // * `promotion-not-offered`: Promotion is not offered to a user. + // * `purchase-complete`: User finishing a purchase. + // * `search`: Product search. + // * `shopping-cart-page-view`: User viewing a shopping cart. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A unique identifier for tracking visitors. + // + // For example, this could be implemented with an HTTP cookie, which should be + // able to uniquely identify a visitor on a single device. This unique + // identifier should not change if the visitor log in/out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analystics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the sesion_id: + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // visitor_id as prefix. + string session_id = 21; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.retail.v2beta.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups (e.g. using Retail API, using different + // recommendation models). + repeated string experiment_ids = 4; + + // Highly recommended for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be a valid + // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] + // for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. + // The value must be a valid + // [SearchResponse.attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] + // for user events that are the result of + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // This token enables us to accurately attribute page view or purchase back to + // the event and the particular predict response containing this + // clicked/purchased product. If user clicks on product K in the + // recommendation results, pass + // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] + // as a URL parameter to product K's page. When recording events on product + // K's page, log the + // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] + // to this field. + string attribution_token = 5; + + // The main product details related to the event. + // + // This field is required for the following event types: + // + // * `add-to-cart` + // * `detail-page-view` + // * `purchase-complete` + // * `search` + // + // In a `search` event, this field represents the products returned to the end + // user on the current page (the end user may have not finished browsing the + // whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [product_details][google.cloud.retail.v2beta.UserEvent.product_details] is + // desired. The end user may have not finished browsing the whole page yet. + repeated ProductDetail product_details = 6; + + // The main auto-completion details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionDetail completion_detail = 22; + + // Extra user event features to include in the recommendation model. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Retail API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // traffic_channel, which is how a user arrives at the site. Users can arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 7; + + // The ID or name of the associated shopping cart. This ID is used + // to associate multiple items added or present in the cart before purchase. + // + // This can only be set for `add-to-cart`, `purchase-complete`, or + // `shopping-cart-page-view` events. + string cart_id = 8; + + // A transaction represents the entire purchase transaction. + // + // Required for `purchase-complete` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + PurchaseTransaction purchase_transaction = 9; + + // The user's search query. + // + // See [SearchRequest.query][google.cloud.retail.v2beta.SearchRequest.query] + // for definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 10; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. + // + // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 16; + + // The order in which products are returned. + // + // See + // [SearchRequest.order_by][google.cloud.retail.v2beta.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 17; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See [SearchRequest.offset][google.cloud.retail.v2beta.SearchRequest.offset] + // for definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + int32 offset = 18; + + // The categories associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + // + // Required for `category-page-view` events. At least one of + // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string page_categories = 11; + + // User information. + UserInfo user_info = 12; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 13; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string referrer_uri = 14; + + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string page_view_id = 15; +} + +// Detailed product information associated with a user event. +message ProductDetail { + // Required. [Product][google.cloud.retail.v2beta.Product] information. + // + // Required field(s): + // + // * [Product.id][google.cloud.retail.v2beta.Product.id] + // + // Optional override field(s): + // + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // + // If any supported optional fields are provided, we will treat them as a full + // override when looking up product information from the catalog. Thus, it is + // important to ensure that the overriding fields are accurate and + // complete. + // + // All other product fields are ignored and instead populated via catalog + // lookup after event ingestion. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Quantity of the product associated with the user event. + // + // For example, this field will be 2 if two products are added to the shopping + // cart for `purchase-complete` event. Required for `add-to-cart` and + // `purchase-complete` event types. + google.protobuf.Int32Value quantity = 2; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionDetail { + // Completion attribution token in + // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2beta.CompleteQueryResponse.attribution_token]. + string completion_attribution_token = 1; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion]. + string selected_suggestion = 2; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion] + // position, starting from 0. + int32 selected_position = 3; +} + +// A transaction represents the entire purchase transaction. +message PurchaseTransaction { + // The transaction ID with a length limit of 128 characters. + string id = 1; + + // Required. Total non-zero revenue or grand total associated with the + // transaction. This value include shipping, tax, or other adjustments to + // total revenue that you want to include as part of your revenue + // calculations. + float revenue = 2 [(google.api.field_behavior) = REQUIRED]; + + // All the taxes associated with the transaction. + float tax = 3; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = + // [revenue][google.cloud.retail.v2beta.PurchaseTransaction.revenue] - + // [tax][google.cloud.retail.v2beta.PurchaseTransaction.tax] - + // [cost][google.cloud.retail.v2beta.PurchaseTransaction.cost] + float cost = 4; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto new file mode 100644 index 00000000..ab7a0b35 --- /dev/null +++ b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto @@ -0,0 +1,190 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; +import "google/cloud/retail/v2beta/purge_config.proto"; +import "google/cloud/retail/v2beta/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for ingesting end user actions on the customer website. +service UserEventService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" + body: "user_event" + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Retail API JavaScript pixel and Google Tag + // Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }; + } + + // Deletes permanently all user events specified by the filter provided. + // Depending on the number of events specified by the filter, this operation + // could take hours or days to complete. To test a filter, use the list + // command first. + rpc PurgeUserEvents(PurgeUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.PurgeUserEventsResponse" + metadata_type: "google.cloud.retail.v2beta.PurgeMetadata" + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // Operation.response is of type ImportResponse. Note that it is + // possible for a subset of the items to be successfully inserted. + // Operation.metadata is of type ImportMetadata. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ImportUserEventsResponse" + metadata_type: "google.cloud.retail.v2beta.ImportMetadata" + }; + } + + // Starts a user event rejoin operation with latest product catalog. Events + // will not be annotated with detailed product information if product is + // missing from the catalog at the time the user event is ingested, and these + // events are stored as unjoined events with a limited usage on training and + // serving. This method can be used to start a join operation on specified + // events with latest version of product catalog. It can also be used to + // correct events joined with the wrong product catalog. A rejoin operation + // can take hours or days to complete. + rpc RejoinUserEvents(RejoinUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "RejoinUserEventsResponse" + metadata_type: "RejoinUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User event to write. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent catalog name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // The URL including cgi-parameters but excluding the hash fragment with a + // length limit of 5,000 characters. This is often more useful than the + // referer URL, because many browsers only send the domain for 3rd party + // requests. + string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + int64 ets = 4; +} + +// Request message for RejoinUserEvents method. +message RejoinUserEventsRequest { + // The scope of user events to be rejoined with the latest product catalog. + // If the rejoining aims at reducing number of unjoined events, set + // UserEventRejoinScope to UNJOINED_EVENTS. + // If the rejoining aims at correcting product catalog information in joined + // events, set UserEventRejoinScope to JOINED_EVENTS. + // If all events needs to be rejoined, set UserEventRejoinScope to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. + enum UserEventRejoinScope { + // Rejoin all events with the latest product catalog, including both joined + // events and unjoined events. + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; + + // Only rejoin joined events with the latest product catalog. + JOINED_EVENTS = 1; + + // Only rejoin unjoined events with the latest product catalog. + UNJOINED_EVENTS = 2; + } + + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the user event rejoin to define the scope and range of the user + // events to be rejoined with the latest product catalog. Defaults to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + // invalid integer value. + UserEventRejoinScope user_event_rejoin_scope = 2; +} + +// Response message for RejoinUserEvents method. +message RejoinUserEventsResponse { + // Number of user events that were joined with latest product catalog. + int64 rejoined_user_events_count = 1; +} + +// Metadata for RejoinUserEvents method. +message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000..553e7103 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2beta_generated_CatalogService_AddCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to add. + */ + // const catalogAttribute = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callAddCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.addCatalogAttribute(request); + console.log(response); + } + + callAddCatalogAttribute(); + // [END retail_v2beta_generated_CatalogService_AddCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js new file mode 100644 index 00000000..b6c393bd --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_CatalogService_GetAttributesConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetAttributesConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getAttributesConfig(request); + console.log(response); + } + + callGetAttributesConfig(); + // [END retail_v2beta_generated_CatalogService_GetAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js new file mode 100644 index 00000000..886e118a --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_CatalogService_GetCompletionConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetCompletionConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getCompletionConfig(request); + console.log(response); + } + + callGetCompletionConfig(); + // [END retail_v2beta_generated_CatalogService_GetCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js new file mode 100644 index 00000000..11ab8856 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js @@ -0,0 +1,58 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2beta_generated_CatalogService_GetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.getDefaultBranch(request); + console.log(response); + } + + callGetDefaultBranch(); + // [END retail_v2beta_generated_CatalogService_GetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js new file mode 100644 index 00000000..a72872cb --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_CatalogService_ListCatalogs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The account resource name with an associated location. + * If the caller does not have permission to list + * Catalog google.cloud.retail.v2beta.Catalog s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Catalog google.cloud.retail.v2beta.Catalog s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListCatalogsResponse.next_page_token google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token, + * received from a previous + * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callListCatalogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCatalogs(); + // [END retail_v2beta_generated_CatalogService_ListCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000..b6d4473a --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, key) { + // [START retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name key of the + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to remove. + */ + // const key = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callRemoveCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + key, + }; + + // Run request + const response = await retailClient.removeCatalogAttribute(request); + console.log(response); + } + + callRemoveCatalogAttribute(); + // [END retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000..42548549 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.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(attributesConfig, catalogAttribute) { + // [START retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + */ + // const attributesConfig = 'abc123' + /** + * Required. The updated + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute. + */ + // const catalogAttribute = {} + /** + * Indicates which fields in the provided + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to update. + * The following are NOT supported: + * * CatalogAttribute.key google.cloud.retail.v2beta.CatalogAttribute.key + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callReplaceCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.replaceCatalogAttribute(request); + console.log(response); + } + + callReplaceCatalogAttribute(); + // [END retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js new file mode 100644 index 00000000..11f667df --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2beta_generated_CatalogService_SetDefaultBranch_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * The final component of the resource name of a branch. + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * If there are no sufficient active products in the targeted branch and + * force google.cloud.retail.v2beta.SetDefaultBranchRequest.force is not + * set, a FAILED_PRECONDITION error is returned. + */ + // const branchId = 'abc123' + /** + * Some note on this request, this can be retrieved by + * CatalogService.GetDefaultBranch google.cloud.retail.v2beta.CatalogService.GetDefaultBranch + * before next valid default branch set occurs. + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const note = 'abc123' + /** + * If set to true, it permits switching to a branch with + * branch_id google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id + * even if it has no sufficient active products. + */ + // const force = true + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callSetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.setDefaultBranch(request); + console.log(response); + } + + callSetDefaultBranch(); + // [END retail_v2beta_generated_CatalogService_SetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js new file mode 100644 index 00000000..dee9a094 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.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(attributesConfig) { + // [START retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The + * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. + */ + // const attributesConfig = {} + /** + * Indicates which fields in the provided + * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. + * The following is the only supported field: + * * AttributesConfig.catalog_attributes google.cloud.retail.v2beta.AttributesConfig.catalog_attributes + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateAttributesConfig() { + // Construct request + const request = { + attributesConfig, + }; + + // Run request + const response = await retailClient.updateAttributesConfig(request); + console.log(response); + } + + callUpdateAttributesConfig(); + // [END retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js new file mode 100644 index 00000000..3f75b996 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.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(catalog) { + // [START retail_v2beta_generated_CatalogService_UpdateCatalog_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Catalog google.cloud.retail.v2beta.Catalog to update. + * If the caller does not have permission to update the + * Catalog google.cloud.retail.v2beta.Catalog, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the Catalog google.cloud.retail.v2beta.Catalog to update does not + * exist, a NOT_FOUND error is returned. + */ + // const catalog = {} + /** + * Indicates which fields in the provided + * Catalog google.cloud.retail.v2beta.Catalog to update. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCatalog() { + // Construct request + const request = { + catalog, + }; + + // Run request + const response = await retailClient.updateCatalog(request); + console.log(response); + } + + callUpdateCatalog(); + // [END retail_v2beta_generated_CatalogService_UpdateCatalog_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js new file mode 100644 index 00000000..d3c451f3 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(completionConfig) { + // [START retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The + * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. + * If the caller does not have permission to update the + * CompletionConfig google.cloud.retail.v2beta.CompletionConfig, then a + * PERMISSION_DENIED error is returned. + * If the CompletionConfig google.cloud.retail.v2beta.CompletionConfig to + * update does not exist, a NOT_FOUND error is returned. + */ + // const completionConfig = {} + /** + * Indicates which fields in the provided + * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. + * The following are the only supported fields: + * * CompletionConfig.matching_order google.cloud.retail.v2beta.CompletionConfig.matching_order + * * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions + * * CompletionConfig.min_prefix_length google.cloud.retail.v2beta.CompletionConfig.min_prefix_length + * * CompletionConfig.auto_learning google.cloud.retail.v2beta.CompletionConfig.auto_learning + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCompletionConfig() { + // Construct request + const request = { + completionConfig, + }; + + // Run request + const response = await retailClient.updateCompletionConfig(request); + console.log(response); + } + + callUpdateCompletionConfig(); + // [END retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js new file mode 100644 index 00000000..28957ff1 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js @@ -0,0 +1,117 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog, query) { + // [START retail_v2beta_generated_CompletionService_CompleteQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Catalog for which the completion is performed. + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * Required. The query used to generate suggestions. + * The maximum number of allowed characters is 255. + */ + // const query = 'abc123' + /** + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see Tags for + * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + */ + // const languageCodes = 'abc123' + /** + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * Supported formats: + * * `UNKNOWN_DEVICE_TYPE` + * * `DESKTOP` + * * `MOBILE` + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + */ + // const deviceType = 'abc123' + /** + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * CompletionService.ImportCompletionData google.cloud.retail.v2beta.CompletionService.ImportCompletionData. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * Current supported values: + * * user-data + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + */ + // const dataset = 'abc123' + /** + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions. + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + catalog, + query, + }; + + // Run request + const response = await retailClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END retail_v2beta_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js new file mode 100644 index 00000000..046aa015 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.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, inputConfig) { + // [START retail_v2beta_generated_CompletionService_ImportCompletionData_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog which the suggestions dataset belongs to. + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callImportCompletionData() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importCompletionData(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportCompletionData(); + // [END retail_v2beta_generated_CompletionService_ImportCompletionData_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js new file mode 100644 index 00000000..670ed9d8 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.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, control, controlId) { + // [START retail_v2beta_generated_ControlService_CreateControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of parent catalog. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Required. The Control to create. + */ + // const control = {} + /** + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callCreateControl() { + // Construct request + const request = { + parent, + control, + controlId, + }; + + // Run request + const response = await retailClient.createControl(request); + console.log(response); + } + + callCreateControl(); + // [END retail_v2beta_generated_ControlService_CreateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js new file mode 100644 index 00000000..fa617382 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ControlService_DeleteControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callDeleteControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteControl(request); + console.log(response); + } + + callDeleteControl(); + // [END retail_v2beta_generated_ControlService_DeleteControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js new file mode 100644 index 00000000..dcc21c72 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ControlService_GetControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callGetControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getControl(request); + console.log(response); + } + + callGetControl(); + // [END retail_v2beta_generated_ControlService_GetControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js new file mode 100644 index 00000000..5de3859c --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_ControlService_ListControls_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + /** + * Optional. A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2beta.ListControlsRequest.filter is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + */ + // const filter = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callListControls() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listControlsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListControls(); + // [END retail_v2beta_generated_ControlService_ListControls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js new file mode 100644 index 00000000..3bc73051 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(control) { + // [START retail_v2beta_generated_ControlService_UpdateControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Control to update. + */ + // const control = {} + /** + * Indicates which fields in the provided + * Control google.cloud.retail.v2beta.Control to update. The following are + * NOT supported: + * * Control.name google.cloud.retail.v2beta.Control.name + * If not set or empty, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callUpdateControl() { + // Construct request + const request = { + control, + }; + + // Run request + const response = await retailClient.updateControl(request); + console.log(response); + } + + callUpdateControl(); + // [END retail_v2beta_generated_ControlService_UpdateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js b/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js new file mode 100644 index 00000000..38b9394c --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js @@ -0,0 +1,161 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, userEvent) { + // [START retail_v2beta_generated_PredictionService_Predict_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see Managing + * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + */ + // const placement = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + */ + // const userEvent = {} + /** + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + */ + // const pageSize = 1234 + /** + * The previous PredictResponse.next_page_token. + */ + // const pageToken = 'abc123' + /** + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * Examples: + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + */ + // const filter = 'abc123' + /** + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + */ + // const validateOnly = true + /** + * Additional domain specific parameters for the predictions. + * Allowed values: + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + */ + // const params = 1234 + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + + // Imports the Retail library + const {PredictionServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new PredictionServiceClient(); + + async function callPredict() { + // Construct request + const request = { + placement, + userEvent, + }; + + // Run request + const response = await retailClient.predict(request); + console.log(response); + } + + callPredict(); + // [END retail_v2beta_generated_PredictionService_Predict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js new file mode 100644 index 00000000..f25e375d --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type. + * Duplicate IDs will be automatically ignored. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * If the total number of place IDs exceeds 2000 for this + * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type after + * adding, then the update will be rejected. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddFulfillmentPlaces(); + // [END retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js new file mode 100644 index 00000000..827fb0fe --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js @@ -0,0 +1,100 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, localInventories) { + // [START retail_v2beta_generated_ProductService_AddLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + */ + // const localInventories = 1234 + /** + * Indicates which inventory fields in the provided list of + * LocalInventory google.cloud.retail.v2beta.LocalInventory to update. The + * field is updated to the provided value. + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const addMask = {} + /** + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddLocalInventories() { + // Construct request + const request = { + product, + localInventories, + }; + + // Run request + const [operation] = await retailClient.addLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddLocalInventories(); + // [END retail_v2beta_generated_ProductService_AddLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js new file mode 100644 index 00000000..b6387d2e --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, product, productId) { + // [START retail_v2beta_generated_ProductService_CreateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + */ + // const parent = 'abc123' + /** + * Required. The Product google.cloud.retail.v2beta.Product to create. + */ + // const product = {} + /** + * Required. The ID to use for the + * Product google.cloud.retail.v2beta.Product, which will become the final + * component of the Product.name google.cloud.retail.v2beta.Product.name. + * If the caller does not have permission to create the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * This field must be unique among all + * Product google.cloud.retail.v2beta.Product s with the same + * parent google.cloud.retail.v2beta.CreateProductRequest.parent. + * Otherwise, an ALREADY_EXISTS error is returned. + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const productId = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + productId, + }; + + // Run request + const response = await retailClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END retail_v2beta_generated_ProductService_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js new file mode 100644 index 00000000..95f4548f --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_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(name) { + // [START retail_v2beta_generated_ProductService_DeleteProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to delete the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2beta.Product to delete does not + * exist, a NOT_FOUND error is returned. + * The Product google.cloud.retail.v2beta.Product to delete can neither be + * a + * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION + * Product google.cloud.retail.v2beta.Product member nor a + * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY + * Product google.cloud.retail.v2beta.Product with more than one + * variants google.cloud.retail.v2beta.Product.Type.VARIANT. Otherwise, an + * INVALID_ARGUMENT error is returned. + * All inventory information for the named + * Product google.cloud.retail.v2beta.Product will be deleted. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END retail_v2beta_generated_ProductService_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js new file mode 100644 index 00000000..d0520d7e --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ProductService_GetProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the requested Product google.cloud.retail.v2beta.Product does not + * exist, a NOT_FOUND error is returned. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END retail_v2beta_generated_ProductService_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js new file mode 100644 index 00000000..f7fe86da --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js @@ -0,0 +1,93 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2beta_generated_ProductService_ImportProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. + */ + // const errorsConfig = {} + /** + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + */ + // const updateMask = {} + /** + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * Only supported when + * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode + * is set to `FULL`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callImportProducts() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProducts(); + // [END retail_v2beta_generated_ProductService_ImportProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js new file mode 100644 index 00000000..d4971483 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js @@ -0,0 +1,132 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_ProductService_ListProducts_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * If the caller does not have permission to list + * Product google.cloud.retail.v2beta.Product s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Product google.cloud.retail.v2beta.Product s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT error is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListProductsResponse.next_page_token google.cloud.retail.v2beta.ListProductsResponse.next_page_token, + * received from a previous + * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2beta.ListProductsRequest.filter is unset. + * * List + * Product.Type.VARIANT google.cloud.retail.v2beta.Product.Type.VARIANT + * Product google.cloud.retail.v2beta.Product s sharing the same + * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY + * Product google.cloud.retail.v2beta.Product. For example: + * `primary_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2beta.Product s bundled in a + * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION + * Product google.cloud.retail.v2beta.Product. + * For example: + * `collection_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2beta.Product s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * If the specified + * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY + * Product google.cloud.retail.v2beta.Product or + * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION + * Product google.cloud.retail.v2beta.Product does not exist, a NOT_FOUND + * error is returned. + */ + // const filter = 'abc123' + /** + * The fields of Product google.cloud.retail.v2beta.Product to return in + * the responses. If not set or empty, the following fields are returned: + * * Product.name google.cloud.retail.v2beta.Product.name + * * Product.id google.cloud.retail.v2beta.Product.id + * * Product.title google.cloud.retail.v2beta.Product.title + * * Product.uri google.cloud.retail.v2beta.Product.uri + * * Product.images google.cloud.retail.v2beta.Product.images + * * Product.price_info google.cloud.retail.v2beta.Product.price_info + * * Product.brands google.cloud.retail.v2beta.Product.brands + * If "*" is provided, all fields are returned. + * Product.name google.cloud.retail.v2beta.Product.name is always returned + * no matter what mask is set. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const readMask = {} + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END retail_v2beta_generated_ProductService_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000..3163edcb --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js @@ -0,0 +1,111 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to Product.fulfillment_info.type . + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveFulfillmentPlaces(); + // [END retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js new file mode 100644 index 00000000..a61bac1d --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, placeIds) { + // [START retail_v2beta_generated_ProductService_RemoveLocalInventories_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + */ + // const placeIds = 'abc123' + /** + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveLocalInventories() { + // Construct request + const request = { + product, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveLocalInventories(); + // [END retail_v2beta_generated_ProductService_RemoveLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js new file mode 100644 index 00000000..ac7ceeff --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js @@ -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 +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inventory) { + // [START retail_v2beta_generated_ProductService_SetInventory_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The inventory information to update. The allowable fields to + * update are: + * * Product.price_info google.cloud.retail.v2beta.Product.price_info + * * Product.availability google.cloud.retail.v2beta.Product.availability + * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info + * The updated inventory fields must be specified in + * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask. + * If SetInventoryRequest.inventory.name is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2beta.Product named in + * Product.name google.cloud.retail.v2beta.Product.name, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2beta.Product to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * If the Product google.cloud.retail.v2beta.Product to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * SetInventoryRequest.set_time google.cloud.retail.v2beta.SetInventoryRequest.set_time. + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in SetInventoryRequest.inventory.fulfillment_info + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types to clear in + * SetInventoryRequest.inventory.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids + * The last update time is recorded for the following inventory fields: + * * Product.price_info google.cloud.retail.v2beta.Product.price_info + * * Product.availability google.cloud.retail.v2beta.Product.availability + * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info + * If a full overwrite of inventory information while ignoring timestamps is + * needed, UpdateProduct should be invoked instead. + */ + // const inventory = {} + /** + * Indicates which inventory fields in the provided + * Product google.cloud.retail.v2beta.Product to update. + * At least one field must be provided. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const setMask = {} + /** + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + */ + // const setTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product with + * name Product.name google.cloud.retail.v2beta.Product.name is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the Product google.cloud.retail.v2beta.Product is created. If set + * to false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callSetInventory() { + // Construct request + const request = { + inventory, + }; + + // Run request + const [operation] = await retailClient.setInventory(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInventory(); + // [END retail_v2beta_generated_ProductService_SetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js new file mode 100644 index 00000000..ed319228 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START retail_v2beta_generated_ProductService_UpdateProduct_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The product to update/create. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2beta.Product to update does not + * exist and + * allow_missing google.cloud.retail.v2beta.UpdateProductRequest.allow_missing + * is not set, a NOT_FOUND error is returned. + */ + // const product = {} + /** + * Indicates which fields in the provided + * Product google.cloud.retail.v2beta.Product to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, a new Product google.cloud.retail.v2beta.Product will be + * created. In this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await retailClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END retail_v2beta_generated_ProductService_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js b/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js new file mode 100644 index 00000000..62f1df1e --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js @@ -0,0 +1,261 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, visitorId) { + // [START retail_v2beta_generated_SearchService_Search_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + */ + // const placement = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + */ + // const query = 'abc123' + /** + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * This should be the same identifier as + * UserEvent.visitor_id google.cloud.retail.v2beta.UserEvent.visitor_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * User information. + */ + // const userInfo = {} + /** + * Maximum number of Product google.cloud.retail.v2beta.Product s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * SearchResponse.next_page_token google.cloud.retail.v2beta.SearchResponse.next_page_token, + * received from a previous + * SearchService.Search google.cloud.retail.v2beta.SearchService.Search + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.retail.v2beta.SearchService.Search + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the Product google.cloud.retail.v2beta.Product s + * deemed by the API as relevant) in search results. This field is only + * considered if + * page_token google.cloud.retail.v2beta.SearchRequest.page_token is unset. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const filter = 'abc123' + /** + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * SearchRequest.canonical_filter google.cloud.retail.v2beta.SearchRequest.canonical_filter + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * See SearchRequest.filter google.cloud.retail.v2beta.SearchRequest.filter + * for more details about filter syntax. + */ + // const canonicalFilter = 'abc123' + /** + * The order in which products are returned. Products can be ordered by + * a field in an Product google.cloud.retail.v2beta.Product object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#order). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const orderBy = 'abc123' + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain products. See more details at this + * user guide (https://cloud.google.com/retail/docs/boosting). + * Notice that if both + * ServingConfig.boost_control_ids google.cloud.retail.v2beta.ServingConfig.boost_control_ids + * and SearchRequest.boost_spec are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + */ + // const boostSpec = {} + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). + */ + // const queryExpansionSpec = {} + /** + * The keys to fetch and rollup the matching + * variant google.cloud.retail.v2beta.Product.Type.VARIANT + * Product google.cloud.retail.v2beta.Product s attributes, + * FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo or + * LocalInventory google.cloud.retail.v2beta.LocalInventory s attributes. + * The attributes from all the matching + * variant google.cloud.retail.v2beta.Product.Type.VARIANT + * Product google.cloud.retail.v2beta.Product s or + * LocalInventory google.cloud.retail.v2beta.LocalInventory s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * For FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * Supported keys are: + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * Product.inventories.attributes map. + * * attributes.key, where key is any key in the + * Product.attributes google.cloud.retail.v2beta.Product.attributes map. + * * pickupInStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "pickup-in-store". + * * shipToStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-1". + * * customFulfillment2.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-2". + * * customFulfillment3.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-3". + * * customFulfillment4.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-4". + * * customFulfillment5.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-5". + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + */ + // const variantRollupKeys = 'abc123' + /** + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * UserEvent.page_categories google.cloud.retail.v2beta.UserEvent.page_categories; + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : "Sales > 2017 Black Friday Deals". + */ + // const pageCategories = 'abc123' + /** + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + */ + // const searchMode = {} + /** + * The specification for personalization. + */ + // const personalizationSpec = {} + + // Imports the Retail library + const {SearchServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + placement, + visitorId, + }; + + // Run request + const iterable = await retailClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END retail_v2beta_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js new file mode 100644 index 00000000..9086bb91 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2beta_generated_ServingConfigService_AddControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callAddControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.addControl(request); + console.log(response); + } + + callAddControl(); + // [END retail_v2beta_generated_ServingConfigService_AddControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js new file mode 100644 index 00000000..fc8ba733 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.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, servingConfig, servingConfigId) { + // [START retail_v2beta_generated_ServingConfigService_CreateServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of parent. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Required. The ServingConfig to create. + */ + // const servingConfig = {} + /** + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const servingConfigId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callCreateServingConfig() { + // Construct request + const request = { + parent, + servingConfig, + servingConfigId, + }; + + // Run request + const response = await retailClient.createServingConfig(request); + console.log(response); + } + + callCreateServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_CreateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000..c9202725 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callDeleteServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteServingConfig(request); + console.log(response); + } + + callDeleteServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js new file mode 100644 index 00000000..be98fd45 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ServingConfigService_GetServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callGetServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getServingConfig(request); + console.log(response); + } + + callGetServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_GetServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000..7a517f3e --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.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 retail_v2beta_generated_ServingConfigService_ListServingConfigs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callListServingConfigs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listServingConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServingConfigs(); + // [END retail_v2beta_generated_ServingConfigService_ListServingConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js new file mode 100644 index 00000000..314b82f9 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2beta_generated_ServingConfigService_RemoveControl_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callRemoveControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.removeControl(request); + console.log(response); + } + + callRemoveControl(); + // [END retail_v2beta_generated_ServingConfigService_RemoveControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js new file mode 100644 index 00000000..f948464a --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig) { + // [START retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ServingConfig to update. + */ + // const servingConfig = {} + /** + * Indicates which fields in the provided + * ServingConfig google.cloud.retail.v2beta.ServingConfig to update. The + * following are NOT supported: + * * ServingConfig.name google.cloud.retail.v2beta.ServingConfig.name + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callUpdateServingConfig() { + // Construct request + const request = { + servingConfig, + }; + + // Run request + const response = await retailClient.updateServingConfig(request); + console.log(response); + } + + callUpdateServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json b/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json new file mode 100644 index 00000000..8e89b650 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json @@ -0,0 +1,2131 @@ +{ + "clientLibrary": { + "name": "nodejs-retail", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.retail.v2beta", + "version": "v2beta" + } + ] + }, + "snippets": [ + { + "regionTag": "retail_v2beta_generated_CatalogService_ListCatalogs_async", + "title": "CatalogService listCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated with the project.", + "canonical": true, + "file": "catalog_service.list_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListCatalogsResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_UpdateCatalog_async", + "title": "CatalogService updateCatalog Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s.", + "canonical": true, + "file": "catalog_service.update_catalog.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": ".google.cloud.retail.v2beta.Catalog" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.Catalog", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_SetDefaultBranch_async", + "title": "CatalogService setDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", + "canonical": true, + "file": "catalog_service.set_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "branch_id", + "type": "TYPE_STRING" + }, + { + "name": "note", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_GetDefaultBranch_async", + "title": "CatalogService getDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] method under a specified parent catalog.", + "canonical": true, + "file": "catalog_service.get_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.GetDefaultBranchResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_GetCompletionConfig_async", + "title": "CatalogService getCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig].", + "canonical": true, + "file": "catalog_service.get_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async", + "title": "CatalogService updateCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s.", + "canonical": true, + "file": "catalog_service.update_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", + "async": true, + "parameters": [ + { + "name": "completion_config", + "type": ".google.cloud.retail.v2beta.CompletionConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_GetAttributesConfig_async", + "title": "CatalogService getAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig].", + "canonical": true, + "file": "catalog_service.get_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async", + "title": "CatalogService updateAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", + "canonical": true, + "file": "catalog_service.update_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": ".google.cloud.retail.v2beta.AttributesConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_AddCatalogAttribute_async", + "title": "CatalogService addCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "catalog_service.add_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2beta.CatalogAttribute" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async", + "title": "CatalogService removeCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.remove_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "key", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async", + "title": "CatalogService replaceCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.replace_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2beta.CatalogAttribute" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CompletionService_CompleteQuery_async", + "title": "CatalogService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 109, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "language_codes", + "type": "TYPE_STRING[]" + }, + { + "name": "device_type", + "type": "TYPE_STRING" + }, + { + "name": "dataset", + "type": "TYPE_STRING" + }, + { + "name": "max_suggestions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.retail.v2beta.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2beta.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CompletionService_ImportCompletionData_async", + "title": "CatalogService importCompletionData Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.import_completion_data.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2beta.CompletionDataInputConfig" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" + }, + "method": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2beta.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_CreateControl_async", + "title": "CatalogService createControl Sample", + "origin": "API_DEFINITION", + "description": " Creates a Control. If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "control_service.create_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "control", + "type": ".google.cloud.retail.v2beta.Control" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_DeleteControl_async", + "title": "CatalogService deleteControl Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Control. If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.delete_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_UpdateControl_async", + "title": "CatalogService updateControl Sample", + "origin": "API_DEFINITION", + "description": " Updates a Control. [Control][google.cloud.retail.v2beta.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", + "async": true, + "parameters": [ + { + "name": "control", + "type": ".google.cloud.retail.v2beta.Control" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_GetControl_async", + "title": "CatalogService getControl Sample", + "origin": "API_DEFINITION", + "description": " Gets a Control.", + "canonical": true, + "file": "control_service.get_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_ListControls_async", + "title": "CatalogService listControls Sample", + "origin": "API_DEFINITION", + "description": " Lists all Controls linked to this catalog.", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListControlsResponse", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_PredictionService_Predict_async", + "title": "CatalogService predict Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation prediction.", + "canonical": true, + "file": "prediction_service.predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 153, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2beta.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.retail.v2beta.PredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.retail.v2beta.PredictionServiceClient" + }, + "method": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.retail.v2beta.PredictionService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_CreateProduct_async", + "title": "CatalogService createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.retail.v2beta.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_GetProduct_async", + "title": "CatalogService getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_ListProducts_async", + "title": "CatalogService listProducts Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Product][google.cloud.retail.v2beta.Product]s.", + "canonical": true, + "file": "product_service.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 124, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "read_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListProductsResponse", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_UpdateProduct_async", + "title": "CatalogService updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.retail.v2beta.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2beta.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_DeleteProduct_async", + "title": "CatalogService deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_ImportProducts_async", + "title": "CatalogService importProducts Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2beta.Product]s to be successfully updated.", + "canonical": true, + "file": "product_service.import_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2beta.ProductInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_SetInventory_async", + "title": "CatalogService setInventory Sample", + "origin": "API_DEFINITION", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2beta.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 116, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", + "async": true, + "parameters": [ + { + "name": "inventory", + "type": ".google.cloud.retail.v2beta.Product" + }, + { + "name": "set_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "set_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async", + "title": "CatalogService addFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async", + "title": "CatalogService removeFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 103, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_AddLocalInventories_async", + "title": "CatalogService addLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Updates local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 92, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "local_inventories", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "add_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_RemoveLocalInventories_async", + "title": "CatalogService removeLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Remove local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_SearchService_Search_async", + "title": "CatalogService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 253, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2beta.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.retail.v2beta.UserInfo" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "canonical_filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "dynamic_facet_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec" + }, + { + "name": "boost_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.BoostSpec" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec" + }, + { + "name": "variant_rollup_keys", + "type": "TYPE_STRING[]" + }, + { + "name": "page_categories", + "type": "TYPE_STRING[]" + }, + { + "name": "search_mode", + "type": ".google.cloud.retail.v2beta.SearchRequest.SearchMode" + }, + { + "name": "personalization_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec" + } + ], + "resultType": ".google.cloud.retail.v2beta.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.retail.v2beta.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2beta.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.retail.v2beta.SearchService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_CreateServingConfig_async", + "title": "CatalogService createServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise a FAILED_PRECONDITION error is returned.", + "canonical": true, + "file": "serving_config_service.create_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "serving_config", + "type": ".google.cloud.retail.v2beta.ServingConfig" + }, + { + "name": "serving_config_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async", + "title": "CatalogService deleteServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.delete_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async", + "title": "CatalogService updateServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates a ServingConfig.", + "canonical": true, + "file": "serving_config_service.update_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": ".google.cloud.retail.v2beta.ServingConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_GetServingConfig_async", + "title": "CatalogService getServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.get_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_ListServingConfigs_async", + "title": "CatalogService listServingConfigs Sample", + "origin": "API_DEFINITION", + "description": " Lists all ServingConfigs linked to this catalog.", + "canonical": true, + "file": "serving_config_service.list_serving_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListServingConfigsResponse", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_AddControl_async", + "title": "CatalogService addControl Sample", + "origin": "API_DEFINITION", + "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", + "canonical": true, + "file": "serving_config_service.add_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_RemoveControl_async", + "title": "CatalogService removeControl Sample", + "origin": "API_DEFINITION", + "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", + "canonical": true, + "file": "serving_config_service.remove_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_WriteUserEvent_async", + "title": "CatalogService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2beta.UserEvent" + } + ], + "resultType": ".google.cloud.retail.v2beta.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_CollectUserEvent_async", + "title": "CatalogService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_PurgeUserEvents_async", + "title": "CatalogService purgeUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", + "canonical": true, + "file": "user_event_service.purge_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 83, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_ImportUserEvents_async", + "title": "CatalogService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2beta.UserEventInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_RejoinUserEvents_async", + "title": "CatalogService rejoinUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", + "canonical": true, + "file": "user_event_service.rejoin_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event_rejoin_scope", + "type": ".google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js new file mode 100644 index 00000000..933ec59d --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2beta_generated_UserEventService_CollectUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + */ + // const userEvent = 'abc123' + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + */ + // const uri = 'abc123' + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + */ + // const ets = 1234 + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END retail_v2beta_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js new file mode 100644 index 00000000..842e14dd --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2beta_generated_UserEventService_ImportUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. `projects/1234/locations/global/catalogs/default_catalog` + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorsConfig = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END retail_v2beta_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js new file mode 100644 index 00000000..059d6944 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js @@ -0,0 +1,91 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2beta_generated_UserEventService_PurgeUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * * `eventType`: Double quoted + * UserEvent.event_type google.cloud.retail.v2beta.UserEvent.event_type + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * Examples: + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * The filtering fields are assumed to have an implicit AND. + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + */ + // const force = true + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callPurgeUserEvents() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeUserEvents(); + // [END retail_v2beta_generated_UserEventService_PurgeUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000..aebf64dc --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_UserEventService_RejoinUserEvents_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + */ + // const userEventRejoinScope = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callRejoinUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await retailClient.rejoinUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRejoinUserEvents(); + // [END retail_v2beta_generated_UserEventService_RejoinUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js new file mode 100644 index 00000000..da53a142 --- /dev/null +++ b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2beta_generated_UserEventService_WriteUserEvent_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END retail_v2beta_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/src/index.ts b/owl-bot-staging/v2beta/src/index.ts new file mode 100644 index 00000000..4f42efab --- /dev/null +++ b/owl-bot-staging/v2beta/src/index.ts @@ -0,0 +1,39 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 v2beta from './v2beta'; +const CatalogServiceClient = v2beta.CatalogServiceClient; +type CatalogServiceClient = v2beta.CatalogServiceClient; +const CompletionServiceClient = v2beta.CompletionServiceClient; +type CompletionServiceClient = v2beta.CompletionServiceClient; +const ControlServiceClient = v2beta.ControlServiceClient; +type ControlServiceClient = v2beta.ControlServiceClient; +const PredictionServiceClient = v2beta.PredictionServiceClient; +type PredictionServiceClient = v2beta.PredictionServiceClient; +const ProductServiceClient = v2beta.ProductServiceClient; +type ProductServiceClient = v2beta.ProductServiceClient; +const SearchServiceClient = v2beta.SearchServiceClient; +type SearchServiceClient = v2beta.SearchServiceClient; +const ServingConfigServiceClient = v2beta.ServingConfigServiceClient; +type ServingConfigServiceClient = v2beta.ServingConfigServiceClient; +const UserEventServiceClient = v2beta.UserEventServiceClient; +type UserEventServiceClient = v2beta.UserEventServiceClient; +export {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +export default {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts new file mode 100644 index 00000000..7c74bd3f --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts @@ -0,0 +1,1865 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/catalog_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './catalog_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for managing catalog configuration. + * @class + * @memberof v2beta + */ +export class CatalogServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + catalogServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CatalogServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CatalogServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listCatalogs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.CatalogService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.catalogServiceStub) { + return this.catalogServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.CatalogService. + this.catalogServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.CatalogService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.CatalogService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const catalogServiceStubMethods = + ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch', 'getCompletionConfig', 'updateCompletionConfig', 'getAttributesConfig', 'updateAttributesConfig', 'addCatalogAttribute', 'removeCatalogAttribute', 'replaceCatalogAttribute']; + for (const methodName of catalogServiceStubMethods) { + const callPromise = this.catalogServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.catalogServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Updates the {@link google.cloud.retail.v2beta.Catalog|Catalog}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Catalog} request.catalog + * Required. The {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.Catalog|Catalog}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Catalog|Catalog} to update does not + * exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2beta.Catalog}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.update_catalog.js + * region_tag:retail_v2beta_generated_CatalogService_UpdateCatalog_async + */ + updateCatalog( + request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|undefined, {}|undefined + ]>; + updateCatalog( + request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): void; + updateCatalog( + request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog.name': request.catalog!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCatalog(request, options, callback); + } +/** + * Set a specified branch id as default branch. API methods such as + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search}, + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct}, + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as + * default, setting + * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` + * as {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} + * to route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.branchId + * The final component of the resource name of a branch. + * + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * + * If there are no sufficient active products in the targeted branch and + * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.force|force} is not + * set, a FAILED_PRECONDITION error is returned. + * @param {string} request.note + * Some note on this request, this can be retrieved by + * {@link google.cloud.retail.v2beta.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} + * before next valid default branch set occurs. + * + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {boolean} request.force + * If set to true, it permits switching to a branch with + * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id|branch_id} + * even if it has no sufficient active products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.set_default_branch.js + * region_tag:retail_v2beta_generated_CatalogService_SetDefaultBranch_async + */ + setDefaultBranch( + request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|undefined, {}|undefined + ]>; + setDefaultBranch( + request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + setDefaultBranch( + request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultBranch(request, options, callback); + } +/** + * Get which branch is currently default branch set by + * {@link google.cloud.retail.v2beta.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} + * method under a specified parent catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2beta.GetDefaultBranchResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.get_default_branch.js + * region_tag:retail_v2beta_generated_CatalogService_GetDefaultBranch_async + */ + getDefaultBranch( + request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|undefined, {}|undefined + ]>; + getDefaultBranch( + request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): void; + getDefaultBranch( + request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.get_completion_config.js + * region_tag:retail_v2beta_generated_CatalogService_GetCompletionConfig_async + */ + getCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|undefined, {}|undefined + ]>; + getCompletionConfig( + request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getCompletionConfig(request, options, callback); + } +/** + * Updates the + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.CompletionConfig} request.completionConfig + * Required. The + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to + * update does not exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. + * The following are the only supported fields: + * + * * {@link google.cloud.retail.v2beta.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link google.cloud.retail.v2beta.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link google.cloud.retail.v2beta.CompletionConfig.auto_learning|CompletionConfig.auto_learning} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.update_completion_config.js + * region_tag:retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async + */ + updateCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|undefined, {}|undefined + ]>; + updateCompletionConfig( + request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'completion_config.name': request.completionConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCompletionConfig(request, options, callback); + } +/** + * Gets an {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.get_attributes_config.js + * region_tag:retail_v2beta_generated_CatalogService_GetAttributesConfig_async + */ + getAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|undefined, {}|undefined + ]>; + getAttributesConfig( + request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getAttributesConfig(request, options, callback); + } +/** + * Updates the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * The catalog attributes in the request will be updated in the catalog, or + * inserted if they do not exist. Existing catalog attributes not included in + * the request will remain unchanged. Attributes that are assigned to + * products, but do not exist at the catalog level, are always included in the + * response. The product attribute is assigned default values for missing + * catalog attribute fields, e.g., searchable and dynamic facetable options. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.AttributesConfig} request.attributesConfig + * Required. The + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. + * The following is the only supported field: + * + * * {@link google.cloud.retail.v2beta.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.update_attributes_config.js + * region_tag:retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async + */ + updateAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|undefined, {}|undefined + ]>; + updateAttributesConfig( + request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config.name': request.attributesConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateAttributesConfig(request, options, callback); + } +/** + * Adds the specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to + * add already exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute + * Required. The + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to add. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.add_catalog_attribute.js + * region_tag:retail_v2beta_generated_CatalogService_AddCatalogAttribute_async + */ + addCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|undefined, {}|undefined + ]>; + addCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.addCatalogAttribute(request, options, callback); + } +/** + * Removes the specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} from the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to + * remove does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {string} request.key + * Required. The attribute name key of the + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to remove. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.remove_catalog_attribute.js + * region_tag:retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async + */ + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|undefined, {}|undefined + ]>; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute(request, options, callback); + } +/** + * Replaces the specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} in the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} by updating + * the catalog attribute with the same + * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to + * replace does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig + * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute + * Required. The updated + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to update. + * The following are NOT supported: + * + * * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.replace_catalog_attribute.js + * region_tag:retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async + */ + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|undefined, {}|undefined + ]>; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig || '', + }); + this.initialize(); + return this.innerApiCalls.replaceCatalogAttribute(request, options, callback); + } + + /** + * Lists all the {@link google.cloud.retail.v2beta.Catalog|Catalog}s associated + * with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2beta.Catalog}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogs( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICatalog[], + protos.google.cloud.retail.v2beta.IListCatalogsRequest|null, + protos.google.cloud.retail.v2beta.IListCatalogsResponse + ]>; + listCatalogs( + request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2beta.ICatalog>): void; + listCatalogs( + request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2beta.ICatalog>): void; + listCatalogs( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2beta.ICatalog>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, + protos.google.cloud.retail.v2beta.ICatalog>): + Promise<[ + protos.google.cloud.retail.v2beta.ICatalog[], + protos.google.cloud.retail.v2beta.IListCatalogsRequest|null, + protos.google.cloud.retail.v2beta.IListCatalogsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listCatalogs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2beta.Catalog} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogsStream( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.createStream( + this.innerApiCalls.listCatalogs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCatalogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Catalog]{@link google.cloud.retail.v2beta.Catalog}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.list_catalogs.js + * region_tag:retail_v2beta_generated_CatalogService_ListCatalogs_async + */ + listCatalogsAsync( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.asyncIterate( + this.innerApiCalls['listCatalogs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.catalogServiceStub && !this._terminated) { + return this.catalogServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json new file mode 100644 index 00000000..cd2aebd1 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json @@ -0,0 +1,90 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.CatalogService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListCatalogs": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCatalog": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "SetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "AddCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "RemoveCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ReplaceCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts new file mode 100644 index 00000000..871a336d --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts @@ -0,0 +1,936 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Auto-completion service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2beta + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importCompletionDataResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportCompletionDataResponse') as gax.protobuf.Type; + const importCompletionDataMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importCompletionData: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importCompletionDataResponse.decode.bind(importCompletionDataResponse), + importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.CompletionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.CompletionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.CompletionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const completionServiceStubMethods = + ['completeQuery', 'importCompletionData']; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Required. Catalog for which the completion is performed. + * + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string} request.visitorId + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {string[]} request.languageCodes + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see [Tags for + * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + * @param {string} request.deviceType + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * + * Supported formats: + * + * * `UNKNOWN_DEVICE_TYPE` + * + * * `DESKTOP` + * + * * `MOBILE` + * + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + * @param {string} request.dataset + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * {@link google.cloud.retail.v2beta.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * + * Current supported values: + * + * * user-data + * + * * cloud-retail + * This option requires additional allowlisting. Before using cloud-retail, + * contact Cloud Retail support team first. + * @param {number} request.maxSuggestions + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. + * + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2beta.CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/completion_service.complete_query.js + * region_tag:retail_v2beta_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|undefined, {}|undefined + ]>; + completeQuery( + request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'catalog': request.catalog || '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + +/** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog which the suggestions dataset belongs to. + * + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2beta.CompletionDataInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/completion_service.import_completion_data.js + * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async + */ + importCompletionData( + request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importCompletionData( + request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importCompletionData( + request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importCompletionData(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importCompletionData()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/completion_service.import_completion_data.js + * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async + */ + async checkImportCompletionDataProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json new file mode 100644 index 00000000..1865fe66 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json @@ -0,0 +1,45 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.CompletionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ImportCompletionData": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts new file mode 100644 index 00000000..297b302a --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts @@ -0,0 +1,1195 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/control_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './control_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for modifying Control. + * @class + * @memberof v2beta + */ +export class ControlServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + controlServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ControlServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ControlServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listControls: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'controls') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.ControlService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.controlServiceStub) { + return this.controlServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ControlService. + this.controlServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ControlService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ControlService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const controlServiceStubMethods = + ['createControl', 'deleteControl', 'updateControl', 'getControl', 'listControls']; + for (const methodName of controlServiceStubMethods) { + const callPromise = this.controlServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.controlServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a Control. + * + * If the {@link google.cloud.retail.v2beta.Control|Control} to create already + * exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent catalog. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {google.cloud.retail.v2beta.Control} request.control + * Required. The Control to create. + * @param {string} request.controlId + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.create_control.js + * region_tag:retail_v2beta_generated_ControlService_CreateControl_async + */ + createControl( + request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|undefined, {}|undefined + ]>; + createControl( + request: protos.google.cloud.retail.v2beta.ICreateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request: protos.google.cloud.retail.v2beta.ICreateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createControl(request, options, callback); + } +/** + * Deletes a Control. + * + * If the {@link google.cloud.retail.v2beta.Control|Control} to delete does not + * exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.delete_control.js + * region_tag:retail_v2beta_generated_ControlService_DeleteControl_async + */ + deleteControl( + request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|undefined, {}|undefined + ]>; + deleteControl( + request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteControl(request, options, callback); + } +/** + * Updates a Control. + * + * {@link google.cloud.retail.v2beta.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link google.cloud.retail.v2beta.Control|Control} to delete does not exist, a + * NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Control} request.control + * Required. The Control to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.Control|Control} to update. The following are + * NOT supported: + * + * * {@link google.cloud.retail.v2beta.Control.name|Control.name} + * + * If not set or empty, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.update_control.js + * region_tag:retail_v2beta_generated_ControlService_UpdateControl_async + */ + updateControl( + request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|undefined, {}|undefined + ]>; + updateControl( + request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'control.name': request.control!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateControl(request, options, callback); + } +/** + * Gets a Control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.get_control.js + * region_tag:retail_v2beta_generated_ControlService_GetControl_async + */ + getControl( + request?: protos.google.cloud.retail.v2beta.IGetControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|undefined, {}|undefined + ]>; + getControl( + request: protos.google.cloud.retail.v2beta.IGetControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request: protos.google.cloud.retail.v2beta.IGetControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request?: protos.google.cloud.retail.v2beta.IGetControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Control]{@link google.cloud.retail.v2beta.Control}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControls( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IControl[], + protos.google.cloud.retail.v2beta.IListControlsRequest|null, + protos.google.cloud.retail.v2beta.IListControlsResponse + ]>; + listControls( + request: protos.google.cloud.retail.v2beta.IListControlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IControl>): void; + listControls( + request: protos.google.cloud.retail.v2beta.IListControlsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IControl>): void; + listControls( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IControl>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IControl>): + Promise<[ + protos.google.cloud.retail.v2beta.IControl[], + protos.google.cloud.retail.v2beta.IListControlsRequest|null, + protos.google.cloud.retail.v2beta.IListControlsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listControls(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Control]{@link google.cloud.retail.v2beta.Control} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControlsStream( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.createStream( + this.innerApiCalls.listControls as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listControls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Control]{@link google.cloud.retail.v2beta.Control}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.list_controls.js + * region_tag:retail_v2beta_generated_ControlService_ListControls_async + */ + listControlsAsync( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.asyncIterate( + this.innerApiCalls['listControls'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.controlServiceStub && !this._terminated) { + return this.controlServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json new file mode 100644 index 00000000..b7572aeb --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ControlService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListControls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json b/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json new file mode 100644 index 00000000..f9c6514c --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json @@ -0,0 +1,571 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.retail.v2beta", + "libraryPackage": "@google-cloud/retail", + "services": { + "CatalogService": { + "clients": { + "grpc": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + } + } + }, + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + } + } + }, + "ControlService": { + "clients": { + "grpc": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "ProductService": { + "clients": { + "grpc": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "ServingConfigService": { + "clients": { + "grpc": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/index.ts b/owl-bot-staging/v2beta/src/v2beta/index.ts new file mode 100644 index 00000000..a7e4f6ba --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/index.ts @@ -0,0 +1,26 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CatalogServiceClient} from './catalog_service_client'; +export {CompletionServiceClient} from './completion_service_client'; +export {ControlServiceClient} from './control_service_client'; +export {PredictionServiceClient} from './prediction_service_client'; +export {ProductServiceClient} from './product_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {ServingConfigServiceClient} from './serving_config_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts new file mode 100644 index 00000000..7f5f710e --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts @@ -0,0 +1,837 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/prediction_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './prediction_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for making recommendation prediction. + * @class + * @memberof v2beta + */ +export class PredictionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + predictionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PredictionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PredictionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.PredictionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.predictionServiceStub) { + return this.predictionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.PredictionService. + this.predictionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.PredictionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.PredictionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const predictionServiceStubMethods = + ['predict']; + for (const methodName of predictionServiceStubMethods) { + const callPromise = this.predictionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.predictionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Makes a recommendation prediction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. Full resource name of the format: + * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} + * The ID of the Recommendations AI placement. Before you can request + * predictions from your model, you must create at least one placement for it. + * For more information, see [Managing + * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). + * + * The full list of available placements can be seen at + * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements + * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * @param {number} request.pageSize + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * @param {string} request.pageToken + * The previous PredictResponse.next_page_token. + * @param {string} request.filter + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * + * Examples: + * + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * @param {boolean} request.validateOnly + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the predictions. + * + * Allowed values: + * + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters, and cannot be empty. Values can be empty, and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2beta.PredictResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/prediction_service.predict.js + * region_tag:retail_v2beta_generated_PredictionService_Predict_async + */ + predict( + request?: protos.google.cloud.retail.v2beta.IPredictRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|undefined, {}|undefined + ]>; + predict( + request: protos.google.cloud.retail.v2beta.IPredictRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request: protos.google.cloud.retail.v2beta.IPredictRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, + {}|null|undefined>): void; + predict( + request?: protos.google.cloud.retail.v2beta.IPredictRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.predictionServiceStub && !this._terminated) { + return this.predictionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json new file mode 100644 index 00000000..ab64c45e --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.PredictionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts new file mode 100644 index 00000000..284f15d5 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts @@ -0,0 +1,2455 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/product_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.retail.v2beta.Product|Product} + * information of the customer's website. + * @class + * @memberof v2beta + */ +export class ProductServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProductServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const importProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportProductsResponse') as gax.protobuf.Type; + const importProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; + const setInventoryResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.SetInventoryResponse') as gax.protobuf.Type; + const setInventoryMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.SetInventoryMetadata') as gax.protobuf.Type; + const addFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse') as gax.protobuf.Type; + const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; + const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; + const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; + const addLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddLocalInventoriesResponse') as gax.protobuf.Type; + const addLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddLocalInventoriesMetadata') as gax.protobuf.Type; + const removeLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse') as gax.protobuf.Type; + const removeLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductsResponse.decode.bind(importProductsResponse), + importProductsMetadata.decode.bind(importProductsMetadata)), + setInventory: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInventoryResponse.decode.bind(setInventoryResponse), + setInventoryMetadata.decode.bind(setInventoryMetadata)), + addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), + addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), + removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), + removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), + addLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), + addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), + removeLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), + removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.ProductService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.productServiceStub) { + return this.productServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ProductService. + this.productServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ProductService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ProductService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const productServiceStubMethods = + ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; + for (const methodName of productServiceStubMethods) { + const callPromise = this.productServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.productServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + * @param {google.cloud.retail.v2beta.Product} request.product + * Required. The {@link google.cloud.retail.v2beta.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the + * {@link google.cloud.retail.v2beta.Product|Product}, which will become the final + * component of the {@link google.cloud.retail.v2beta.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * This field must be unique among all + * {@link google.cloud.retail.v2beta.Product|Product}s with the same + * {@link google.cloud.retail.v2beta.CreateProductRequest.parent|parent}. + * Otherwise, an ALREADY_EXISTS error is returned. + * + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.create_product.js + * region_tag:retail_v2beta_generated_ProductService_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.retail.v2beta.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.retail.v2beta.ICreateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link google.cloud.retail.v2beta.Product|Product} does not + * exist, a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.get_product.js + * region_tag:retail_v2beta_generated_ProductService_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.retail.v2beta.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.retail.v2beta.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.retail.v2beta.IGetProductRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.retail.v2beta.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Updates a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Product} request.product + * Required. The product to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not + * exist and + * {@link google.cloud.retail.v2beta.UpdateProductRequest.allow_missing|allow_missing} + * is not set, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.Product|Product} to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, a new {@link google.cloud.retail.v2beta.Product|Product} will be + * created. In this situation, `update_mask` is ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.update_product.js + * region_tag:retail_v2beta_generated_ProductService_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Deletes a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to delete does not + * exist, a NOT_FOUND error is returned. + * + * The {@link google.cloud.retail.v2beta.Product|Product} to delete can neither be + * a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} member nor a + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} with more than one + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link google.cloud.retail.v2beta.Product|Product} will be deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.delete_product.js + * region_tag:retail_v2beta_generated_ProductService_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } + +/** + * Bulk import of multiple {@link google.cloud.retail.v2beta.Product|Product}s. + * + * Request processing may be synchronous. No partial updating is supported. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * {@link google.cloud.retail.v2beta.Product|Product}s to be successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + * @param {string} request.requestId + * Deprecated. This field has no effect. + * @param {google.cloud.retail.v2beta.ProductInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + * @param {google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * {@link google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * + * Only supported when + * {@link google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} + * is set to `FULL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.import_products.js + * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async + */ + importProducts( + request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProducts( + request: protos.google.cloud.retail.v2beta.IImportProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request: protos.google.cloud.retail.v2beta.IImportProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProducts( + request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.import_products.js + * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async + */ + async checkImportProductsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates inventory information for a + * {@link google.cloud.retail.v2beta.Product|Product} while respecting the last + * update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, updates are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct}, + * the specified inventory field value(s) will overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update time for the specified inventory fields will be overwritten to the + * time of the + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} or + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2beta.CreateProductRequest.product|CreateProductRequest.product}, + * then any pre-existing inventory information for this product will be used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information will be preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2beta.ProductService.SetInventory|SetInventory}, + * {@link google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Product} request.inventory + * Required. The inventory information to update. The allowable fields to + * update are: + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an + * INVALID_ARGUMENT error is returned. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.Product|Product} named in + * {@link google.cloud.retail.v2beta.Product.name|Product.name}, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. + * + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} + * + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link |SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} + * + * The last update time is recorded for the following inventory fields: + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, {@link |UpdateProduct} should be invoked instead. + * @param {google.protobuf.FieldMask} request.setMask + * Indicates which inventory fields in the provided + * {@link google.cloud.retail.v2beta.Product|Product} to update. + * + * At least one field must be provided. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.setTime + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} with + * name {@link google.cloud.retail.v2beta.Product.name|Product.name} is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the {@link google.cloud.retail.v2beta.Product|Product} is created. If set + * to false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.set_inventory.js + * region_tag:retail_v2beta_generated_ProductService_SetInventory_async + */ + setInventory( + request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setInventory( + request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setInventory( + request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'inventory.name': request.inventory!.name || '', + }); + this.initialize(); + return this.innerApiCalls.setInventory(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setInventory()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.set_inventory.js + * region_tag:retail_v2beta_generated_ProductService_SetInventory_async + */ + async checkSetInventoryProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally adds place IDs to + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}. + * Duplicate IDs will be automatically ignored. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * If the total number of place IDs exceeds 2000 for this + * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type} after + * adding, then the update will be rejected. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async + */ + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async + */ + async checkAddFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Incrementally removes place IDs from a + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async + */ + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async + */ + async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates local inventory information for a + * {@link google.cloud.retail.v2beta.Product|Product} at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {number[]} request.localInventories + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + * @param {google.protobuf.FieldMask} request.addMask + * Indicates which inventory fields in the provided list of + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory} to update. The + * field is updated to the provided value. + * + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async + */ + addLocalInventories( + request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + addLocalInventories( + request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + addLocalInventories( + request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.addLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `addLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async + */ + async checkAddLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Remove local inventory information for a + * {@link google.cloud.retail.v2beta.Product|Product} at a list of places at a + * removal timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {string[]} request.placeIds + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async + */ + removeLocalInventories( + request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + removeLocalInventories( + request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + removeLocalInventories( + request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product': request.product || '', + }); + this.initialize(); + return this.innerApiCalls.removeLocalInventories(request, options, callback); + } +/** + * Check the status of the long running operation returned by `removeLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async + */ + async checkRemoveLocalInventoriesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.retail.v2beta.Product|Product}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} or + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.retail.v2beta.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct[], + protos.google.cloud.retail.v2beta.IListProductsRequest|null, + protos.google.cloud.retail.v2beta.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.retail.v2beta.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IProduct>): void; + listProducts( + request: protos.google.cloud.retail.v2beta.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IProduct>): void; + listProducts( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IProduct>): + Promise<[ + protos.google.cloud.retail.v2beta.IProduct[], + protos.google.cloud.retail.v2beta.IListProductsRequest|null, + protos.google.cloud.retail.v2beta.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} or + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2beta.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} or + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.retail.v2beta.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.list_products.js + * region_tag:retail_v2beta_generated_ProductService_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.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 unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.productServiceStub && !this._terminated) { + return this.productServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json new file mode 100644 index 00000000..459b579d --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json @@ -0,0 +1,99 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ProductService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "GetProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ListProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "UpdateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "DeleteProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportProducts": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "SetInventory": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts new file mode 100644 index 00000000..d3d87c33 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts @@ -0,0 +1,1480 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2beta + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + search: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.SearchService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.SearchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.SearchService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const searchServiceStubMethods = + ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2beta.ISearchRequest|null, + protos.google.cloud.retail.v2beta.ISearchResponse + ]>; + search( + request: protos.google.cloud.retail.v2beta.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): void; + search( + request: protos.google.cloud.retail.v2beta.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): void; + search( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): + Promise<[ + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2beta.ISearchRequest|null, + protos.google.cloud.retail.v2beta.ISearchResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `search`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the search engine placement, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and [SearchRequest.boost_spec] are set, the boost conditions from both + * places are evaluated. If a search request matches multiple boost + * conditions, the final boost score is equal to the sum of the boost scores + * from all matched boost conditions. + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link |Product.inventories.attributes} map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/search_service.search.js + * region_tag:retail_v2beta_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'placement': request.placement || '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath(project:string,location:string,catalog:string,branch:string) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json new file mode 100644 index 00000000..82de0f81 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.SearchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts new file mode 100644 index 00000000..9f807827 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts @@ -0,0 +1,1333 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/serving_config_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './serving_config_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service for modifying ServingConfig. + * @class + * @memberof v2beta + */ +export class ServingConfigServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + servingConfigServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServingConfigServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServingConfigServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listServingConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'servingConfigs') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.ServingConfigService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.servingConfigServiceStub) { + return this.servingConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ServingConfigService. + this.servingConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ServingConfigService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ServingConfigService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const servingConfigServiceStubMethods = + ['createServingConfig', 'deleteServingConfig', 'updateServingConfig', 'getServingConfig', 'listServingConfigs', 'addControl', 'removeControl']; + for (const methodName of servingConfigServiceStubMethods) { + const callPromise = this.servingConfigServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.servingConfigServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a ServingConfig. + * + * A maximum of 100 {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig}s + * are allowed in a {@link google.cloud.retail.v2beta.Catalog|Catalog}, otherwise + * a FAILED_PRECONDITION error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig + * Required. The ServingConfig to create. + * @param {string} request.servingConfigId + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.create_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_CreateServingConfig_async + */ + createServingConfig( + request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|undefined, {}|undefined + ]>; + createServingConfig( + request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createServingConfig(request, options, callback); + } +/** + * Deletes a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.delete_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async + */ + deleteServingConfig( + request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|undefined, {}|undefined + ]>; + deleteServingConfig( + request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteServingConfig(request, options, callback); + } +/** + * Updates a ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig + * Required. The ServingConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2beta.ServingConfig.name|ServingConfig.name} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.update_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async + */ + updateServingConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|undefined, {}|undefined + ]>; + updateServingConfig( + request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config.name': request.servingConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateServingConfig(request, options, callback); + } +/** + * Gets a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.get_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_GetServingConfig_async + */ + getServingConfig( + request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|undefined, {}|undefined + ]>; + getServingConfig( + request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getServingConfig(request, options, callback); + } +/** + * Enables a Control on the specified ServingConfig. + * The control is added in the last position of the list of controls + * it belongs to (e.g. if it's a facet spec control it will be applied + * in the last position of servingConfig.facetSpecIds) + * Returns a ALREADY_EXISTS error if the control has already been applied. + * Returns a FAILED_PRECONDITION error if the addition could exceed maximum + * number of control allowed for that type of control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.add_control.js + * region_tag:retail_v2beta_generated_ServingConfigService_AddControl_async + */ + addControl( + request?: protos.google.cloud.retail.v2beta.IAddControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|undefined, {}|undefined + ]>; + addControl( + request: protos.google.cloud.retail.v2beta.IAddControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request: protos.google.cloud.retail.v2beta.IAddControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request?: protos.google.cloud.retail.v2beta.IAddControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config': request.servingConfig || '', + }); + this.initialize(); + return this.innerApiCalls.addControl(request, options, callback); + } +/** + * Disables a Control on the specified ServingConfig. + * The control is removed from the ServingConfig. + * Returns a NOT_FOUND error if the Control is not enabled for the + * ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.remove_control.js + * region_tag:retail_v2beta_generated_ServingConfigService_RemoveControl_async + */ + removeControl( + request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|undefined, {}|undefined + ]>; + removeControl( + request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'serving_config': request.servingConfig || '', + }); + this.initialize(); + return this.innerApiCalls.removeControl(request, options, callback); + } + + /** + * Lists all ServingConfigs linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigs( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig[], + protos.google.cloud.retail.v2beta.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse + ]>; + listServingConfigs( + request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IServingConfig>): void; + listServingConfigs( + request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IServingConfig>): void; + listServingConfigs( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IServingConfig>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IServingConfig>): + Promise<[ + protos.google.cloud.retail.v2beta.IServingConfig[], + protos.google.cloud.retail.v2beta.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listServingConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigsStream( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.createStream( + this.innerApiCalls.listServingConfigs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServingConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.list_serving_configs.js + * region_tag:retail_v2beta_generated_ServingConfigService_ListServingConfigs_async + */ + listServingConfigsAsync( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.asyncIterate( + this.innerApiCalls['listServingConfigs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.servingConfigServiceStub && !this._terminated) { + return this.servingConfigServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json new file mode 100644 index 00000000..2d17b527 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ServingConfigService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServingConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts new file mode 100644 index 00000000..86906d7b --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts @@ -0,0 +1,1201 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on the customer website. + * @class + * @memberof v2beta + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const purgeUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.PurgeUserEventsResponse') as gax.protobuf.Type; + const purgeUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.PurgeMetadata') as gax.protobuf.Type; + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportUserEventsResponse') as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; + const rejoinUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RejoinUserEventsResponse') as gax.protobuf.Type; + const rejoinUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RejoinUserEventsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), + purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata)), + rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), + rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.UserEventService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.UserEventService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.UserEventService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const userEventServiceStubMethods = + ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2beta.UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.write_user_event.js + * region_tag:retail_v2beta_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|undefined, {}|undefined + ]>; + writeUserEvent( + request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } +/** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.collect_user_event.js + * region_tag:retail_v2beta_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|undefined, {}|undefined + ]>; + collectUserEvent( + request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + +/** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + * @param {string} request.filter + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * + * * `eventType`: Double quoted + * {@link google.cloud.retail.v2beta.UserEvent.event_type|UserEvent.event_type} + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * + * Examples: + * + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * + * The filtering fields are assumed to have an implicit AND. + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async + */ + purgeUserEvents( + request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeUserEvents( + request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeUserEvents( + request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.purgeUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async + */ + async checkPurgeUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. `projects/1234/locations/global/catalogs/default_catalog` + * @param {google.cloud.retail.v2beta.UserEventInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.import_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importUserEvents( + request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.import_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a user event rejoin operation with latest product catalog. Events + * will not be annotated with detailed product information if product is + * missing from the catalog at the time the user event is ingested, and these + * events are stored as unjoined events with a limited usage on training and + * serving. This method can be used to start a join operation on specified + * events with latest version of product catalog. It can also be used to + * correct events joined with the wrong product catalog. A rejoin operation + * can take hours or days to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async + */ + rejoinUserEvents( + request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + rejoinUserEvents( + request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + rejoinUserEvents( + request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.rejoinUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `rejoinUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async + */ + async checkRejoinUserEventsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project:string,location:string,catalog:string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project:string,location:string,catalog:string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath(project:string,location:string,catalog:string,control:string) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,catalog:string,branch:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json new file mode 100644 index 00000000..f5bd2bae --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.UserEventService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "CollectUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "PurgeUserEvents": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportUserEvents": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "RejoinUserEvents": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json new file mode 100644 index 00000000..7cee73e6 --- /dev/null +++ b/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json @@ -0,0 +1,20 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..57b7c7be --- /dev/null +++ b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js @@ -0,0 +1,34 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const retail = require('@google-cloud/retail'); + +function main() { + const catalogServiceClient = new retail.CatalogServiceClient(); + const completionServiceClient = new retail.CompletionServiceClient(); + const controlServiceClient = new retail.ControlServiceClient(); + const predictionServiceClient = new retail.PredictionServiceClient(); + const productServiceClient = new retail.ProductServiceClient(); + const searchServiceClient = new retail.SearchServiceClient(); + const servingConfigServiceClient = new retail.ServingConfigServiceClient(); + const userEventServiceClient = new retail.UserEventServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..25eaae42 --- /dev/null +++ b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts @@ -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. ** + +import {CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient} from '@google-cloud/retail'; + +// check that the client class type name can be used +function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { + client.close(); +} +function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { + client.close(); +} +function doStuffWithControlServiceClient(client: ControlServiceClient) { + client.close(); +} +function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { + client.close(); +} +function doStuffWithProductServiceClient(client: ProductServiceClient) { + client.close(); +} +function doStuffWithSearchServiceClient(client: SearchServiceClient) { + client.close(); +} +function doStuffWithServingConfigServiceClient(client: ServingConfigServiceClient) { + client.close(); +} +function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const catalogServiceClient = new CatalogServiceClient(); + doStuffWithCatalogServiceClient(catalogServiceClient); + // check that the client instance can be created + const completionServiceClient = new CompletionServiceClient(); + doStuffWithCompletionServiceClient(completionServiceClient); + // check that the client instance can be created + const controlServiceClient = new ControlServiceClient(); + doStuffWithControlServiceClient(controlServiceClient); + // check that the client instance can be created + const predictionServiceClient = new PredictionServiceClient(); + doStuffWithPredictionServiceClient(predictionServiceClient); + // check that the client instance can be created + const productServiceClient = new ProductServiceClient(); + doStuffWithProductServiceClient(productServiceClient); + // check that the client instance can be created + const searchServiceClient = new SearchServiceClient(); + doStuffWithSearchServiceClient(searchServiceClient); + // check that the client instance can be created + const servingConfigServiceClient = new ServingConfigServiceClient(); + doStuffWithServingConfigServiceClient(servingConfigServiceClient); + // check that the client instance can be created + const userEventServiceClient = new UserEventServiceClient(); + doStuffWithUserEventServiceClient(userEventServiceClient); +} + +main(); diff --git a/owl-bot-staging/v2beta/system-test/install.ts b/owl-bot-staging/v2beta/system-test/install.ts new file mode 100644 index 00000000..8ec45222 --- /dev/null +++ b/owl-bot-staging/v2beta/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/v2beta/test/gapic_catalog_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts new file mode 100644 index 00000000..c264bc2d --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts @@ -0,0 +1,1790 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as catalogserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.CatalogServiceClient', () => { + it('has servicePath', () => { + const servicePath = catalogserviceModule.v2beta.CatalogServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = catalogserviceModule.v2beta.CatalogServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = catalogserviceModule.v2beta.CatalogServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + await client.initialize(); + assert(client.catalogServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.catalogServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('updateCatalog', () => { + it('invokes updateCatalog without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); + const [response] = await client.updateCatalog(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()); + client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCatalog( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICatalog|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCatalog with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedHeaderRequestParams = "catalog.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCatalog(request), expectedError); + assert((client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCatalog with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); + request.catalog = {}; + request.catalog.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCatalog(request), expectedError); + }); + }); + + describe('setDefaultBranch', () => { + it('invokes setDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultBranch( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultBranch(request), expectedError); + assert((client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultBranch(request), expectedError); + }); + }); + + describe('getDefaultBranch', () => { + it('invokes getDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.getDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse()); + client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDefaultBranch( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDefaultBranch(request), expectedError); + assert((client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDefaultBranch(request), expectedError); + }); + }); + + describe('getCompletionConfig', () => { + it('invokes getCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); + client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCompletionConfig(request), expectedError); + assert((client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCompletionConfig(request), expectedError); + }); + }); + + describe('updateCompletionConfig', () => { + it('invokes updateCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); + client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedHeaderRequestParams = "completion_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + assert((client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); + request.completionConfig = {}; + request.completionConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + }); + }); + + describe('getAttributesConfig', () => { + it('invokes getAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAttributesConfig(request), expectedError); + assert((client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAttributesConfig(request), expectedError); + }); + }); + + describe('updateAttributesConfig', () => { + it('invokes updateAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedHeaderRequestParams = "attributes_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + assert((client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); + request.attributesConfig = {}; + request.attributesConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + }); + }); + + describe('addCatalogAttribute', () => { + it('invokes addCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.addCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + }); + }); + + describe('removeCatalogAttribute', () => { + it('invokes removeCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.removeCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + }); + }); + + describe('replaceCatalogAttribute', () => { + it('invokes replaceCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.replaceCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes replaceCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.replaceCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes replaceCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedHeaderRequestParams = "attributes_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes replaceCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); + request.attributesConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + }); + }); + + describe('listCatalogs', () => { + it('invokes listCatalogs without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.listCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogs without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCatalogs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICatalog[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCatalogs with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCatalogs(request), expectedError); + assert((client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCatalogsStream without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCatalogsStream with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); + assert.strictEqual( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; + const iterable = client.listCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCatalogs with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts new file mode 100644 index 00000000..26af45db --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts @@ -0,0 +1,703 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as completionserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2beta.CompletionServiceClient', () => { + it('has servicePath', () => { + const servicePath = completionserviceModule.v2beta.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = completionserviceModule.v2beta.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v2beta.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryResponse()); + client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompleteQueryResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); + request.catalog = ''; + const expectedHeaderRequestParams = "catalog="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + assert((client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); + request.catalog = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('importCompletionData', () => { + it('invokes importCompletionData without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); + const [operation] = await client.importCompletionData(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCompletionData( + request, + (err?: Error|null, + result?: LROperation|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.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importCompletionData with call error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importCompletionData(request), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importCompletionData with LRO error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportCompletionDataProgress without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportCompletionDataProgress with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts new file mode 100644 index 00000000..4ba4bd3c --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts @@ -0,0 +1,1108 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as controlserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.ControlServiceClient', () => { + it('has servicePath', () => { + const servicePath = controlserviceModule.v2beta.ControlServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = controlserviceModule.v2beta.ControlServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = controlserviceModule.v2beta.ControlServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new controlserviceModule.v2beta.ControlServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + await client.initialize(); + assert(client.controlServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.controlServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createControl', () => { + it('invokes createControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); + const [response] = await client.createControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createControl(request), expectedError); + assert((client.innerApiCalls.createControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createControl(request), expectedError); + }); + }); + + describe('deleteControl', () => { + it('invokes deleteControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteControl( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteControl(request), expectedError); + assert((client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteControl(request), expectedError); + }); + }); + + describe('updateControl', () => { + it('invokes updateControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); + const [response] = await client.updateControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedHeaderRequestParams = "control.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateControl(request), expectedError); + assert((client.innerApiCalls.updateControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); + request.control = {}; + request.control.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateControl(request), expectedError); + }); + }); + + describe('getControl', () => { + it('invokes getControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); + const [response] = await client.getControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); + client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getControl(request), expectedError); + assert((client.innerApiCalls.getControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getControl(request), expectedError); + }); + }); + + describe('listControls', () => { + it('invokes listControls without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); + const [response] = await client.listControls(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listControls without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listControls( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listControls with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listControls(request), expectedError); + assert((client.innerApiCalls.listControls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listControlsStream without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.descriptors.page.listControls.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Control) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listControls, request)); + assert.strictEqual( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listControlsStream with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Control) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listControls, request)); + assert.strictEqual( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listControls without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IControl[] = []; + const iterable = client.listControlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listControls with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listControlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.IControl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts new file mode 100644 index 00000000..ca636e40 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts @@ -0,0 +1,543 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as predictionserviceModule from '../src'; + +import {protobuf} 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('v2beta.PredictionServiceClient', () => { + it('has servicePath', () => { + const servicePath = predictionserviceModule.v2beta.PredictionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = predictionserviceModule.v2beta.PredictionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = predictionserviceModule.v2beta.PredictionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + await client.initialize(); + assert(client.predictionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.predictionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('predict', () => { + it('invokes predict without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCall(expectedResponse); + const [response] = await client.predict(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictResponse()); + client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.predict( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IPredictResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes predict with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + assert((client.innerApiCalls.predict as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes predict with closed client', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); + request.placement = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts new file mode 100644 index 00000000..b483f593 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts @@ -0,0 +1,2046 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as productserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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('v2beta.ProductServiceClient', () => { + it('has servicePath', () => { + const servicePath = productserviceModule.v2beta.ProductServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productserviceModule.v2beta.ProductServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productserviceModule.v2beta.ProductServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productserviceModule.v2beta.ProductServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + await client.initialize(); + assert(client.productServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); + request.product = {}; + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('importProducts', () => { + it('invokes importProducts without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProducts( + request, + (err?: Error|null, + result?: LROperation|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.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProducts with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProducts(request), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProducts with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductsProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductsProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setInventory', () => { + it('invokes setInventory without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInventory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInventory( + request, + (err?: Error|null, + result?: LROperation|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.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setInventory with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInventory(request), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setInventory with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); + request.inventory = {}; + request.inventory.name = ''; + const expectedHeaderRequestParams = "inventory.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.setInventory as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkSetInventoryProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInventoryProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkSetInventoryProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addFulfillmentPlaces', () => { + it('invokes addFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeFulfillmentPlaces', () => { + it('invokes removeFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeFulfillmentPlaces( + request, + (err?: Error|null, + result?: LROperation|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.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('addLocalInventories', () => { + it('invokes addLocalInventories without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.addLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addLocalInventories with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addLocalInventories(request), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAddLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('removeLocalInventories', () => { + it('invokes removeLocalInventories without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); + const [operation] = await client.removeLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeLocalInventories( + request, + (err?: Error|null, + result?: LROperation|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.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeLocalInventories with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeLocalInventories(request), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); + request.product = ''; + const expectedHeaderRequestParams = "product="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRemoveLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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.retail.v2beta.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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.retail.v2beta.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts new file mode 100644 index 00000000..f654dd43 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts @@ -0,0 +1,770 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.SearchServiceClient', () => { + it('has servicePath', () => { + const servicePath = searchserviceModule.v2beta.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = searchserviceModule.v2beta.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v2beta.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v2beta.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + assert((client.innerApiCalls.search as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert.strictEqual( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); + request.placement = ''; + const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('branch', () => { + const fakePath = "/rendered/path/branch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.branchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts new file mode 100644 index 00000000..f7adf822 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts @@ -0,0 +1,1302 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as servingconfigserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.ServingConfigServiceClient', () => { + it('has servicePath', () => { + const servicePath = servingconfigserviceModule.v2beta.ServingConfigServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = servingconfigserviceModule.v2beta.ServingConfigServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = servingconfigserviceModule.v2beta.ServingConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + await client.initialize(); + assert(client.servingConfigServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servingConfigServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createServingConfig', () => { + it('invokes createServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.createServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createServingConfig(request), expectedError); + assert((client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createServingConfig(request), expectedError); + }); + }); + + describe('deleteServingConfig', () => { + it('invokes deleteServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServingConfig( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteServingConfig(request), expectedError); + assert((client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteServingConfig(request), expectedError); + }); + }); + + describe('updateServingConfig', () => { + it('invokes updateServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedHeaderRequestParams = "serving_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateServingConfig(request), expectedError); + assert((client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); + request.servingConfig = {}; + request.servingConfig.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateServingConfig(request), expectedError); + }); + }); + + describe('getServingConfig', () => { + it('invokes getServingConfig without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getServingConfig(request), expectedError); + assert((client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getServingConfig(request), expectedError); + }); + }); + + describe('addControl', () => { + it('invokes addControl without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); + const [response] = await client.addControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addControl with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addControl(request), expectedError); + assert((client.innerApiCalls.addControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addControl with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); + request.servingConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addControl(request), expectedError); + }); + }); + + describe('removeControl', () => { + it('invokes removeControl without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); + const [response] = await client.removeControl(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); + client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeControl with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); + request.servingConfig = ''; + const expectedHeaderRequestParams = "serving_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeControl(request), expectedError); + assert((client.innerApiCalls.removeControl as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeControl with closed client', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); + request.servingConfig = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeControl(request), expectedError); + }); + }); + + describe('listServingConfigs', () => { + it('invokes listServingConfigs without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listServingConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServingConfigs without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServingConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServingConfigs(request), expectedError); + assert((client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServingConfigsStream without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + ]; + client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.ServingConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listServingConfigsStream with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.ServingConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServingConfigs without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), + ]; + client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = []; + const iterable = client.listServingConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServingConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts new file mode 100644 index 00000000..dd385461 --- /dev/null +++ b/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts @@ -0,0 +1,1088 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as usereventserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} 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('v2beta.UserEventServiceClient', () => { + it('has servicePath', () => { + const servicePath = usereventserviceModule.v2beta.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = usereventserviceModule.v2beta.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v2beta.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.UserEvent()); + client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IUserEvent|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + assert((client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); + client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + assert((client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('purgeUserEvents', () => { + it('invokes purgeUserEvents without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeUserEvents with call error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeUserEvents(request), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('rejoinUserEvents', () => { + it('invokes rejoinUserEvents without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.rejoinUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejoinUserEvents( + request, + (err?: Error|null, + result?: LROperation|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.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes rejoinUserEvents with call error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rejoinUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkRejoinUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRejoinUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('catalog', () => { + const fakePath = "/rendered/path/catalog"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('control', () => { + const fakePath = "/rendered/path/control"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + control: "controlValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.controlPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, "controlValue"); + assert((client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + branch: "branchValue", + product: "productValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2beta/tsconfig.json b/owl-bot-staging/v2beta/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v2beta/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/v2beta/webpack.config.js b/owl-bot-staging/v2beta/webpack.config.js new file mode 100644 index 00000000..f2c58f25 --- /dev/null +++ b/owl-bot-staging/v2beta/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CatalogService', + filename: './catalog-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From aed01869cb45721b0ba33670495e2702a73c9e6d Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 1 Jun 2022 03:52:22 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- owl-bot-staging/v2/.eslintignore | 7 - owl-bot-staging/v2/.eslintrc.json | 3 - owl-bot-staging/v2/.gitignore | 14 - owl-bot-staging/v2/.jsdoc.js | 55 - owl-bot-staging/v2/.mocharc.js | 33 - owl-bot-staging/v2/.prettierrc.js | 22 - owl-bot-staging/v2/README.md | 1 - owl-bot-staging/v2/linkinator.config.json | 16 - owl-bot-staging/v2/package.json | 69 - .../google/cloud/retail/v2/catalog.proto | 110 - .../cloud/retail/v2/catalog_service.proto | 246 -- .../google/cloud/retail/v2/common.proto | 491 --- .../cloud/retail/v2/completion_service.proto | 205 -- .../cloud/retail/v2/import_config.proto | 401 --- .../cloud/retail/v2/prediction_service.proto | 204 -- .../google/cloud/retail/v2/product.proto | 558 ---- .../cloud/retail/v2/product_service.proto | 838 ------ .../google/cloud/retail/v2/promotion.proto | 40 - .../google/cloud/retail/v2/purge_config.proto | 82 - .../cloud/retail/v2/search_service.proto | 854 ------ .../google/cloud/retail/v2/user_event.proto | 343 --- .../cloud/retail/v2/user_event_service.proto | 190 -- .../v2/catalog_service.get_default_branch.js | 58 - .../v2/catalog_service.list_catalogs.js | 83 - .../v2/catalog_service.set_default_branch.js | 81 - .../v2/catalog_service.update_catalog.js | 70 - .../v2/completion_service.complete_query.js | 116 - ...mpletion_service.import_completion_data.js | 73 - .../v2/prediction_service.predict.js | 170 -- .../product_service.add_fulfillment_places.js | 115 - .../product_service.add_local_inventories.js | 99 - .../v2/product_service.create_product.js | 80 - .../v2/product_service.delete_product.js | 74 - .../v2/product_service.get_product.js | 65 - .../v2/product_service.import_products.js | 99 - .../v2/product_service.list_products.js | 130 - ...oduct_service.remove_fulfillment_places.js | 112 - ...roduct_service.remove_local_inventories.js | 85 - .../v2/product_service.set_inventory.js | 124 - .../v2/product_service.update_product.js | 84 - .../generated/v2/search_service.search.js | 288 -- ...ippet_metadata.google.cloud.retail.v2.json | 1303 -------- .../user_event_service.collect_user_event.js | 78 - .../user_event_service.import_user_events.js | 69 - .../user_event_service.purge_user_events.js | 90 - .../user_event_service.rejoin_user_events.js | 67 - .../v2/user_event_service.write_user_event.js | 64 - owl-bot-staging/v2/src/index.ts | 35 - .../v2/src/v2/catalog_service_client.ts | 1058 ------- .../src/v2/catalog_service_client_config.json | 55 - .../v2/src/v2/catalog_service_proto_list.json | 15 - .../v2/src/v2/completion_service_client.ts | 701 ----- .../v2/completion_service_client_config.json | 45 - .../src/v2/completion_service_proto_list.json | 15 - owl-bot-staging/v2/src/v2/gapic_metadata.json | 345 --- owl-bot-staging/v2/src/v2/index.ts | 24 - .../v2/src/v2/prediction_service_client.ts | 613 ---- .../v2/prediction_service_client_config.json | 40 - .../src/v2/prediction_service_proto_list.json | 15 - .../v2/src/v2/product_service_client.ts | 2223 -------------- .../src/v2/product_service_client_config.json | 99 - .../v2/src/v2/product_service_proto_list.json | 15 - .../v2/src/v2/search_service_client.ts | 1324 --------- .../src/v2/search_service_client_config.json | 40 - .../v2/src/v2/search_service_proto_list.json | 15 - .../v2/src/v2/user_event_service_client.ts | 966 ------ .../v2/user_event_service_client_config.json | 78 - .../src/v2/user_event_service_proto_list.json | 15 - .../system-test/fixtures/sample/src/index.js | 32 - .../system-test/fixtures/sample/src/index.ts | 62 - owl-bot-staging/v2/system-test/install.ts | 49 - .../v2/test/gapic_catalog_service_v2.ts | 903 ------ .../v2/test/gapic_completion_service_v2.ts | 503 ---- .../v2/test/gapic_prediction_service_v2.ts | 343 --- .../v2/test/gapic_product_service_v2.ts | 1846 ------------ .../v2/test/gapic_search_service_v2.ts | 570 ---- .../v2/test/gapic_user_event_service_v2.ts | 888 ------ owl-bot-staging/v2/tsconfig.json | 19 - owl-bot-staging/v2/webpack.config.js | 64 - owl-bot-staging/v2alpha/.eslintignore | 7 - owl-bot-staging/v2alpha/.eslintrc.json | 3 - owl-bot-staging/v2alpha/.gitignore | 14 - owl-bot-staging/v2alpha/.jsdoc.js | 55 - owl-bot-staging/v2alpha/.mocharc.js | 33 - owl-bot-staging/v2alpha/.prettierrc.js | 22 - owl-bot-staging/v2alpha/README.md | 1 - .../v2alpha/linkinator.config.json | 16 - owl-bot-staging/v2alpha/package.json | 71 - .../google/cloud/retail/v2alpha/catalog.proto | 397 --- .../retail/v2alpha/catalog_service.proto | 478 --- .../google/cloud/retail/v2alpha/common.proto | 761 ----- .../retail/v2alpha/completion_service.proto | 199 -- .../google/cloud/retail/v2alpha/control.proto | 92 - .../retail/v2alpha/control_service.proto | 184 -- .../cloud/retail/v2alpha/export_config.proto | 77 - .../cloud/retail/v2alpha/import_config.proto | 397 --- .../retail/v2alpha/prediction_service.proto | 194 -- .../google/cloud/retail/v2alpha/product.proto | 567 ---- .../retail/v2alpha/product_service.proto | 882 ------ .../cloud/retail/v2alpha/promotion.proto | 40 - .../cloud/retail/v2alpha/purge_config.proto | 171 -- .../cloud/retail/v2alpha/search_service.proto | 832 ------ .../cloud/retail/v2alpha/serving_config.proto | 247 -- .../v2alpha/serving_config_service.proto | 241 -- .../cloud/retail/v2alpha/user_event.proto | 344 --- .../retail/v2alpha/user_event_service.proto | 190 -- .../catalog_service.add_catalog_attribute.js | 65 - .../catalog_service.get_attributes_config.js | 59 - .../catalog_service.get_completion_config.js | 59 - .../catalog_service.get_default_branch.js | 58 - .../v2alpha/catalog_service.list_catalogs.js | 83 - ...atalog_service.remove_catalog_attribute.js | 65 - ...talog_service.replace_catalog_attribute.js | 73 - .../catalog_service.set_default_branch.js | 81 - ...atalog_service.update_attributes_config.js | 67 - .../v2alpha/catalog_service.update_catalog.js | 70 - ...atalog_service.update_completion_config.js | 75 - .../completion_service.complete_query.js | 117 - ...mpletion_service.import_completion_data.js | 73 - .../v2alpha/control_service.create_control.js | 72 - .../v2alpha/control_service.delete_control.js | 59 - .../v2alpha/control_service.get_control.js | 59 - .../v2alpha/control_service.list_controls.js | 79 - .../v2alpha/control_service.update_control.js | 66 - .../v2alpha/prediction_service.predict.js | 161 - .../product_service.add_fulfillment_places.js | 115 - .../product_service.add_local_inventories.js | 100 - .../v2alpha/product_service.create_product.js | 80 - .../v2alpha/product_service.delete_product.js | 75 - .../v2alpha/product_service.get_product.js | 65 - .../product_service.import_products.js | 93 - .../v2alpha/product_service.list_products.js | 141 - .../v2alpha/product_service.purge_products.js | 101 - ...oduct_service.remove_fulfillment_places.js | 111 - ...roduct_service.remove_local_inventories.js | 85 - .../v2alpha/product_service.set_inventory.js | 124 - .../v2alpha/product_service.update_product.js | 80 - .../v2alpha/search_service.search.js | 281 -- .../serving_config_service.add_control.js | 65 - ...ng_config_service.create_serving_config.js | 72 - ...ng_config_service.delete_serving_config.js | 59 - ...rving_config_service.get_serving_config.js | 59 - ...ing_config_service.list_serving_configs.js | 72 - .../serving_config_service.remove_control.js | 65 - ...ng_config_service.update_serving_config.js | 66 - ..._metadata.google.cloud.retail.v2alpha.json | 2187 -------------- .../user_event_service.collect_user_event.js | 78 - .../user_event_service.import_user_events.js | 69 - .../user_event_service.purge_user_events.js | 91 - .../user_event_service.rejoin_user_events.js | 67 - .../user_event_service.write_user_event.js | 64 - owl-bot-staging/v2alpha/src/index.ts | 39 - .../src/v2alpha/catalog_service_client.ts | 1865 ------------ .../catalog_service_client_config.json | 90 - .../v2alpha/catalog_service_proto_list.json | 20 - .../src/v2alpha/completion_service_client.ts | 936 ------ .../completion_service_client_config.json | 45 - .../completion_service_proto_list.json | 20 - .../src/v2alpha/control_service_client.ts | 1195 -------- .../control_service_client_config.json | 46 - .../v2alpha/control_service_proto_list.json | 20 - .../v2alpha/src/v2alpha/gapic_metadata.json | 581 ---- owl-bot-staging/v2alpha/src/v2alpha/index.ts | 26 - .../src/v2alpha/prediction_service_client.ts | 837 ------ .../prediction_service_client_config.json | 40 - .../prediction_service_proto_list.json | 20 - .../src/v2alpha/product_service_client.ts | 2641 ----------------- .../product_service_client_config.json | 104 - .../v2alpha/product_service_proto_list.json | 20 - .../src/v2alpha/search_service_client.ts | 1537 ---------- .../v2alpha/search_service_client_config.json | 40 - .../v2alpha/search_service_proto_list.json | 20 - .../v2alpha/serving_config_service_client.ts | 1334 --------- .../serving_config_service_client_config.json | 54 - .../serving_config_service_proto_list.json | 20 - .../src/v2alpha/user_event_service_client.ts | 1201 -------- .../user_event_service_client_config.json | 78 - .../user_event_service_proto_list.json | 20 - .../system-test/fixtures/sample/src/index.js | 34 - .../system-test/fixtures/sample/src/index.ts | 74 - .../v2alpha/system-test/install.ts | 49 - .../test/gapic_catalog_service_v2alpha.ts | 1790 ----------- .../test/gapic_completion_service_v2alpha.ts | 703 ----- .../test/gapic_control_service_v2alpha.ts | 1108 ------- .../test/gapic_prediction_service_v2alpha.ts | 543 ---- .../test/gapic_product_service_v2alpha.ts | 2190 -------------- .../test/gapic_search_service_v2alpha.ts | 770 ----- .../gapic_serving_config_service_v2alpha.ts | 1302 -------- .../test/gapic_user_event_service_v2alpha.ts | 1088 ------- owl-bot-staging/v2alpha/tsconfig.json | 19 - owl-bot-staging/v2alpha/webpack.config.js | 64 - owl-bot-staging/v2beta/.eslintignore | 7 - owl-bot-staging/v2beta/.eslintrc.json | 3 - owl-bot-staging/v2beta/.gitignore | 14 - owl-bot-staging/v2beta/.jsdoc.js | 55 - owl-bot-staging/v2beta/.mocharc.js | 33 - owl-bot-staging/v2beta/.prettierrc.js | 22 - owl-bot-staging/v2beta/README.md | 1 - owl-bot-staging/v2beta/linkinator.config.json | 16 - owl-bot-staging/v2beta/package.json | 71 - .../google/cloud/retail/v2beta/catalog.proto | 397 --- .../cloud/retail/v2beta/catalog_service.proto | 478 --- .../google/cloud/retail/v2beta/common.proto | 760 ----- .../retail/v2beta/completion_service.proto | 199 -- .../google/cloud/retail/v2beta/control.proto | 84 - .../cloud/retail/v2beta/control_service.proto | 184 -- .../cloud/retail/v2beta/export_config.proto | 77 - .../cloud/retail/v2beta/import_config.proto | 397 --- .../retail/v2beta/prediction_service.proto | 194 -- .../google/cloud/retail/v2beta/product.proto | 566 ---- .../cloud/retail/v2beta/product_service.proto | 829 ------ .../cloud/retail/v2beta/promotion.proto | 40 - .../cloud/retail/v2beta/purge_config.proto | 80 - .../cloud/retail/v2beta/search_service.proto | 791 ----- .../cloud/retail/v2beta/serving_config.proto | 247 -- .../v2beta/serving_config_service.proto | 240 -- .../cloud/retail/v2beta/user_event.proto | 342 --- .../retail/v2beta/user_event_service.proto | 190 -- .../catalog_service.add_catalog_attribute.js | 65 - .../catalog_service.get_attributes_config.js | 59 - .../catalog_service.get_completion_config.js | 59 - .../catalog_service.get_default_branch.js | 58 - .../v2beta/catalog_service.list_catalogs.js | 83 - ...atalog_service.remove_catalog_attribute.js | 65 - ...talog_service.replace_catalog_attribute.js | 73 - .../catalog_service.set_default_branch.js | 81 - ...atalog_service.update_attributes_config.js | 67 - .../v2beta/catalog_service.update_catalog.js | 70 - ...atalog_service.update_completion_config.js | 75 - .../completion_service.complete_query.js | 117 - ...mpletion_service.import_completion_data.js | 73 - .../v2beta/control_service.create_control.js | 72 - .../v2beta/control_service.delete_control.js | 59 - .../v2beta/control_service.get_control.js | 59 - .../v2beta/control_service.list_controls.js | 79 - .../v2beta/control_service.update_control.js | 66 - .../v2beta/prediction_service.predict.js | 161 - .../product_service.add_fulfillment_places.js | 115 - .../product_service.add_local_inventories.js | 100 - .../v2beta/product_service.create_product.js | 80 - .../v2beta/product_service.delete_product.js | 75 - .../v2beta/product_service.get_product.js | 65 - .../v2beta/product_service.import_products.js | 93 - .../v2beta/product_service.list_products.js | 132 - ...oduct_service.remove_fulfillment_places.js | 111 - ...roduct_service.remove_local_inventories.js | 85 - .../v2beta/product_service.set_inventory.js | 124 - .../v2beta/product_service.update_product.js | 80 - .../generated/v2beta/search_service.search.js | 261 -- .../serving_config_service.add_control.js | 65 - ...ng_config_service.create_serving_config.js | 72 - ...ng_config_service.delete_serving_config.js | 59 - ...rving_config_service.get_serving_config.js | 59 - ...ing_config_service.list_serving_configs.js | 72 - .../serving_config_service.remove_control.js | 65 - ...ng_config_service.update_serving_config.js | 66 - ...t_metadata.google.cloud.retail.v2beta.json | 2131 ------------- .../user_event_service.collect_user_event.js | 78 - .../user_event_service.import_user_events.js | 69 - .../user_event_service.purge_user_events.js | 91 - .../user_event_service.rejoin_user_events.js | 67 - .../user_event_service.write_user_event.js | 64 - owl-bot-staging/v2beta/src/index.ts | 39 - .../src/v2beta/catalog_service_client.ts | 1865 ------------ .../v2beta/catalog_service_client_config.json | 90 - .../v2beta/catalog_service_proto_list.json | 20 - .../src/v2beta/completion_service_client.ts | 936 ------ .../completion_service_client_config.json | 45 - .../v2beta/completion_service_proto_list.json | 20 - .../src/v2beta/control_service_client.ts | 1195 -------- .../v2beta/control_service_client_config.json | 46 - .../v2beta/control_service_proto_list.json | 20 - .../v2beta/src/v2beta/gapic_metadata.json | 571 ---- owl-bot-staging/v2beta/src/v2beta/index.ts | 26 - .../src/v2beta/prediction_service_client.ts | 837 ------ .../prediction_service_client_config.json | 40 - .../v2beta/prediction_service_proto_list.json | 20 - .../src/v2beta/product_service_client.ts | 2455 --------------- .../v2beta/product_service_client_config.json | 99 - .../v2beta/product_service_proto_list.json | 20 - .../src/v2beta/search_service_client.ts | 1480 --------- .../v2beta/search_service_client_config.json | 40 - .../src/v2beta/search_service_proto_list.json | 20 - .../v2beta/serving_config_service_client.ts | 1333 --------- .../serving_config_service_client_config.json | 54 - .../serving_config_service_proto_list.json | 20 - .../src/v2beta/user_event_service_client.ts | 1201 -------- .../user_event_service_client_config.json | 78 - .../v2beta/user_event_service_proto_list.json | 20 - .../system-test/fixtures/sample/src/index.js | 34 - .../system-test/fixtures/sample/src/index.ts | 74 - owl-bot-staging/v2beta/system-test/install.ts | 49 - .../test/gapic_catalog_service_v2beta.ts | 1790 ----------- .../test/gapic_completion_service_v2beta.ts | 703 ----- .../test/gapic_control_service_v2beta.ts | 1108 ------- .../test/gapic_prediction_service_v2beta.ts | 543 ---- .../test/gapic_product_service_v2beta.ts | 2046 ------------- .../test/gapic_search_service_v2beta.ts | 770 ----- .../gapic_serving_config_service_v2beta.ts | 1302 -------- .../test/gapic_user_event_service_v2beta.ts | 1088 ------- owl-bot-staging/v2beta/tsconfig.json | 19 - owl-bot-staging/v2beta/webpack.config.js | 64 - protos/google/cloud/retail/v2/catalog.proto | 16 +- protos/google/cloud/retail/v2/common.proto | 36 +- .../cloud/retail/v2/completion_service.proto | 15 +- .../cloud/retail/v2/import_config.proto | 11 +- .../cloud/retail/v2/prediction_service.proto | 16 +- protos/google/cloud/retail/v2/product.proto | 4 +- .../cloud/retail/v2/product_service.proto | 36 +- .../google/cloud/retail/v2/purge_config.proto | 5 +- .../cloud/retail/v2/search_service.proto | 108 +- .../google/cloud/retail/v2/user_event.proto | 9 +- protos/protos.d.ts | 115 + protos/protos.js | 328 +- protos/protos.json | 41 +- .../v2/completion_service.complete_query.js | 6 +- .../v2/prediction_service.predict.js | 11 +- .../v2/product_service.import_products.js | 10 +- ...oduct_service.remove_fulfillment_places.js | 3 +- .../v2/product_service.update_product.js | 4 + samples/generated/v2/search_service.search.js | 40 +- ...ippet_metadata.google.cloud.retail.v2.json | 22 +- src/v2/completion_service_client.ts | 6 +- src/v2/prediction_service_client.ts | 12 +- src/v2/product_service_client.ts | 23 +- src/v2/search_service_client.ts | 117 +- 326 files changed, 880 insertions(+), 90809 deletions(-) delete mode 100644 owl-bot-staging/v2/.eslintignore delete mode 100644 owl-bot-staging/v2/.eslintrc.json delete mode 100644 owl-bot-staging/v2/.gitignore delete mode 100644 owl-bot-staging/v2/.jsdoc.js delete mode 100644 owl-bot-staging/v2/.mocharc.js delete mode 100644 owl-bot-staging/v2/.prettierrc.js delete mode 100644 owl-bot-staging/v2/README.md delete mode 100644 owl-bot-staging/v2/linkinator.config.json delete mode 100644 owl-bot-staging/v2/package.json delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto delete mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/search_service.search.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/v2/src/index.ts delete mode 100644 owl-bot-staging/v2/src/v2/catalog_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/catalog_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/catalog_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/completion_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/completion_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/completion_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/gapic_metadata.json delete mode 100644 owl-bot-staging/v2/src/v2/index.ts delete mode 100644 owl-bot-staging/v2/src/v2/prediction_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/prediction_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/prediction_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/product_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/product_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/product_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/search_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/search_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/search_service_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/user_event_service_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/user_event_service_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v2/system-test/install.ts delete mode 100644 owl-bot-staging/v2/test/gapic_catalog_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_completion_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_prediction_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_product_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_search_service_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_user_event_service_v2.ts delete mode 100644 owl-bot-staging/v2/tsconfig.json delete mode 100644 owl-bot-staging/v2/webpack.config.js delete mode 100644 owl-bot-staging/v2alpha/.eslintignore delete mode 100644 owl-bot-staging/v2alpha/.eslintrc.json delete mode 100644 owl-bot-staging/v2alpha/.gitignore delete mode 100644 owl-bot-staging/v2alpha/.jsdoc.js delete mode 100644 owl-bot-staging/v2alpha/.mocharc.js delete mode 100644 owl-bot-staging/v2alpha/.prettierrc.js delete mode 100644 owl-bot-staging/v2alpha/README.md delete mode 100644 owl-bot-staging/v2alpha/linkinator.config.json delete mode 100644 owl-bot-staging/v2alpha/package.json delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto delete mode 100644 owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js delete mode 100644 owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/v2alpha/src/index.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/index.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json delete mode 100644 owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v2alpha/system-test/install.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts delete mode 100644 owl-bot-staging/v2alpha/tsconfig.json delete mode 100644 owl-bot-staging/v2alpha/webpack.config.js delete mode 100644 owl-bot-staging/v2beta/.eslintignore delete mode 100644 owl-bot-staging/v2beta/.eslintrc.json delete mode 100644 owl-bot-staging/v2beta/.gitignore delete mode 100644 owl-bot-staging/v2beta/.jsdoc.js delete mode 100644 owl-bot-staging/v2beta/.mocharc.js delete mode 100644 owl-bot-staging/v2beta/.prettierrc.js delete mode 100644 owl-bot-staging/v2beta/README.md delete mode 100644 owl-bot-staging/v2beta/linkinator.config.json delete mode 100644 owl-bot-staging/v2beta/package.json delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto delete mode 100644 owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js delete mode 100644 owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/v2beta/src/index.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/index.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts delete mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json delete mode 100644 owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v2beta/system-test/install.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts delete mode 100644 owl-bot-staging/v2beta/tsconfig.json delete mode 100644 owl-bot-staging/v2beta/webpack.config.js diff --git a/owl-bot-staging/v2/.eslintignore b/owl-bot-staging/v2/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v2/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v2/.eslintrc.json b/owl-bot-staging/v2/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v2/.gitignore b/owl-bot-staging/v2/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v2/.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/v2/.jsdoc.js b/owl-bot-staging/v2/.jsdoc.js deleted file mode 100644 index 19729810..00000000 --- a/owl-bot-staging/v2/.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/retail', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v2/.mocharc.js b/owl-bot-staging/v2/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v2/.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/v2/.prettierrc.js b/owl-bot-staging/v2/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v2/.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/v2/README.md b/owl-bot-staging/v2/README.md deleted file mode 100644 index 822c4573..00000000 --- a/owl-bot-staging/v2/README.md +++ /dev/null @@ -1 +0,0 @@ -Retail: Nodejs Client diff --git a/owl-bot-staging/v2/linkinator.config.json b/owl-bot-staging/v2/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v2/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/v2/package.json b/owl-bot-staging/v2/package.json deleted file mode 100644 index 09d9ddf3..00000000 --- a/owl-bot-staging/v2/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@google-cloud/retail", - "version": "0.1.0", - "description": "Retail client for Node.js", - "repository": "googleapis/nodejs-retail", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google retail", - "retail", - "catalog service", - "completion service", - "prediction service", - "product service", - "search service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto deleted file mode 100644 index 119afaf3..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog.proto +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Configures what level the product should be uploaded with regards to -// how users will be send events and how predictions will be made. -message ProductLevelConfig { - // The type of [Product][google.cloud.retail.v2.Product]s allowed to be - // ingested into the catalog. Acceptable values are: - // - // * `primary` (default): You can ingest - // [Product][google.cloud.retail.v2.Product]s of all types. When - // ingesting a [Product][google.cloud.retail.v2.Product], its type will - // default to - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] if - // unset. - // * `variant` (incompatible with Retail Search): You can only - // ingest - // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s. This means - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] - // cannot be empty. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `variant` and - // [merchant_center_product_id_field][google.cloud.retail.v2.ProductLevelConfig.merchant_center_product_id_field] - // is `itemGroupId`, an INVALID_ARGUMENT error is returned. - // - // See [Product - // levels](https://cloud.google.com/retail/docs/catalog#product-levels) - // for more details. - string ingestion_product_type = 1; - - // Which field of [Merchant Center - // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be - // imported as [Product.id][google.cloud.retail.v2.Product.id]. Acceptable - // values are: - // - // * `offerId` (default): Import `offerId` as the product ID. - // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail - // API will choose one item from the ones with the same `itemGroupId`, and - // use it to represent the item group. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `itemGroupId` and - // [ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] - // is `variant`, an INVALID_ARGUMENT error is returned. - // - // See [Product - // levels](https://cloud.google.com/retail/docs/catalog#product-levels) - // for more details. - string merchant_center_product_id_field = 2; -} - -// The catalog configuration. -message Catalog { - option (google.api.resource) = { - type: "retail.googleapis.com/Catalog" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" - }; - - // Required. Immutable. The fully qualified resource name of the catalog. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. Immutable. The catalog display name. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. The product level configuration. - ProductLevelConfig product_level_config = 4 - [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto deleted file mode 100644 index ec7a23a8..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/catalog_service.proto +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/catalog.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for managing catalog configuration. -service CatalogService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with - // the project. - rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*}/catalogs" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates the [Catalog][google.cloud.retail.v2.Catalog]s. - rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { - option (google.api.http) = { - patch: "/v2/{catalog.name=projects/*/locations/*/catalogs/*}" - body: "catalog" - }; - option (google.api.method_signature) = "catalog,update_mask"; - } - - // Set a specified branch id as default branch. API methods such as - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search], - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] - // will treat requests using "default_branch" to the actual branch id set as - // default. - // - // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as - // default, setting - // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent - // to setting - // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/1`. - // - // Using multiple branches can be useful when developers would like - // to have a staging branch to test and verify for future usage. When it - // becomes ready, developers switch on the staging branch using this API while - // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` - // as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to - // route the traffic to this staging branch. - // - // CAUTION: If you have live predict/search traffic, switching the default - // branch could potentially cause outages if the ID space of the new branch is - // very different from the old one. - // - // More specifically: - // - // * PredictionService will only return product IDs from branch {newBranch}. - // * SearchService will only return product IDs from branch {newBranch} - // (if branch is not explicitly set). - // * UserEventService will only join events with products from branch - // {newBranch}. - rpc SetDefaultBranch(SetDefaultBranchRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" - body: "*" - }; - option (google.api.method_signature) = "catalog"; - } - - // Get which branch is currently default branch set by - // [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] - // method under a specified parent catalog. - rpc GetDefaultBranch(GetDefaultBranchRequest) - returns (GetDefaultBranchResponse) { - option (google.api.http) = { - get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" - }; - option (google.api.method_signature) = "catalog"; - } -} - -// Request for -// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] -// method. -message ListCatalogsRequest { - // Required. The account resource name with an associated location. - // - // If the caller does not have permission to list - // [Catalog][google.cloud.retail.v2.Catalog]s under this location, regardless - // of whether or not this location exists, a PERMISSION_DENIED error is - // returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of [Catalog][google.cloud.retail.v2.Catalog]s to return. If - // unspecified, defaults to 50. The maximum allowed value is 1000. Values - // above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 2; - - // A page token - // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2.ListCatalogsResponse.next_page_token], - // received from a previous - // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; -} - -// Response for -// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] -// method. -message ListCatalogsResponse { - // All the customer's [Catalog][google.cloud.retail.v2.Catalog]s. - repeated Catalog catalogs = 1; - - // A token that can be sent as - // [ListCatalogsRequest.page_token][google.cloud.retail.v2.ListCatalogsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request for -// [CatalogService.UpdateCatalog][google.cloud.retail.v2.CatalogService.UpdateCatalog] -// method. -message UpdateCatalogRequest { - // Required. The [Catalog][google.cloud.retail.v2.Catalog] to update. - // - // If the caller does not have permission to update the - // [Catalog][google.cloud.retail.v2.Catalog], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // If the [Catalog][google.cloud.retail.v2.Catalog] to update does not exist, - // a NOT_FOUND error is returned. - Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Catalog][google.cloud.retail.v2.Catalog] to update. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message to set a specified branch as new default_branch. -message SetDefaultBranchRequest { - // Full resource name of the catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // The final component of the resource name of a branch. - // - // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - // error is returned. - // - // If there are no sufficient active products in the targeted branch and - // [force][google.cloud.retail.v2.SetDefaultBranchRequest.force] is not set, a - // FAILED_PRECONDITION error is returned. - string branch_id = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Some note on this request, this can be retrieved by - // [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch] - // before next valid default branch set occurs. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string note = 3; - - // If set to true, it permits switching to a branch with - // [branch_id][google.cloud.retail.v2.SetDefaultBranchRequest.branch_id] even - // if it has no sufficient active products. - bool force = 4; -} - -// Request message to show which branch is currently the default branch. -message GetDefaultBranchRequest { - // The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; -} - -// Response message of -// [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch]. -message GetDefaultBranchResponse { - // Full resource name of the branch id currently set as default branch. - string branch = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // The time when this branch is set to default. - google.protobuf.Timestamp set_time = 2; - - // This corresponds to - // [SetDefaultBranchRequest.note][google.cloud.retail.v2.SetDefaultBranchRequest.note] - // field, when this branch was set as default. - string note = 3; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto deleted file mode 100644 index 386a9aa6..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/common.proto +++ /dev/null @@ -1,491 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// An intended audience of the [Product][google.cloud.retail.v2.Product] for -// whom it's sold. -message Audience { - // The genders of the audience. Strongly encouraged to use the standard - // values: "male", "female", "unisex". - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [gender](https://support.google.com/merchants/answer/6324479). Schema.org - // property - // [Product.audience.suggestedGender](https://schema.org/suggestedGender). - repeated string genders = 1; - - // The age groups of the audience. Strongly encouraged to use the standard - // values: "newborn" (up to 3 months old), "infant" (3–12 months old), - // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically - // teens or older). - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [age_group](https://support.google.com/merchants/answer/6324463). - // Schema.org property - // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and - // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). - repeated string age_groups = 2; -} - -// The color information of a [Product][google.cloud.retail.v2.Product]. -message ColorInfo { - // The standard color families. Strongly recommended to use the following - // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", - // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and - // "Mixed". Normally it is expected to have only 1 color family. May consider - // using single "Mixed" instead of multiple values. - // - // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string color_families = 1; - - // The color display names, which may be different from standard color family - // names, such as the color aliases used in the website frontend. Normally - // it is expected to have only 1 color. May consider using single "Mixed" - // instead of multiple values. - // - // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string colors = 2; -} - -// A custom attribute that is not explicitly modeled in -// [Product][google.cloud.retail.v2.Product]. -message CustomAttribute { - // The textual values of this custom attribute. For example, `["yellow", - // "green"]` when the key is "color". - // - // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated string text = 1; - - // The numerical values of this custom attribute. For example, `[2.3, 15.4]` - // when the key is "lengths_cm". - // - // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated double numbers = 2; - - // This field is normally ignored unless - // [AttributesConfig.attribute_config_level][] of the - // [Catalog][google.cloud.retail.v2.Catalog] is set to the deprecated - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level - // attribute configuration, see [Configuration - // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). - // If true, custom attribute values are searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - // - // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. - // - // Only set if type [text][google.cloud.retail.v2.CustomAttribute.text] is - // set. Otherwise, a INVALID_ARGUMENT error is returned. - optional bool searchable = 3 [deprecated = true]; - - // This field is normally ignored unless - // [AttributesConfig.attribute_config_level][] of the - // [Catalog][google.cloud.retail.v2.Catalog] is set to the deprecated - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level - // attribute configuration, see [Configuration - // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). - // If true, custom attribute values are indexed, so that they can be filtered, - // faceted or boosted in - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - // - // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. - // - // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter], - // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] - // and - // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] - // for more details. - optional bool indexable = 4 [deprecated = true]; -} - -// Fulfillment information, such as the store IDs for in-store pickup or region -// IDs for different shipping methods. -message FulfillmentInfo { - // The fulfillment type, including commonly used types (such as pickup in - // store and same day delivery), and custom types. Customers have to map - // custom types to their display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - string type = 1; - - // The IDs for this [type][google.cloud.retail.v2.FulfillmentInfo.type], such - // as the store IDs for - // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2.FulfillmentInfo.type] - // or the region IDs for - // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2.FulfillmentInfo.type]. - // - // A maximum of 3000 values are allowed. Each value must be a string with a - // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such - // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string place_ids = 2; -} - -// [Product][google.cloud.retail.v2.Product] image. Recommendations AI and -// Retail Search do not use product images to improve prediction and search -// results. However, product images can be returned in results, and are shown in -// prediction or search previews in the console. -message Image { - // Required. URI of the image. - // - // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // Height of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 height = 2; - - // Width of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 width = 3; -} - -// A floating point interval. -message Interval { - // The lower bound of the interval. If neither of the min fields are set, then - // the lower bound is negative infinity. - // - // This field must be not larger than - // [max][google.cloud.retail.v2.Interval.max]. Otherwise, an INVALID_ARGUMENT - // error is returned. - oneof min { - // Inclusive lower bound. - double minimum = 1; - - // Exclusive lower bound. - double exclusive_minimum = 2; - } - - // The upper bound of the interval. If neither of the max fields are set, then - // the upper bound is positive infinity. - // - // This field must be not smaller than - // [min][google.cloud.retail.v2.Interval.min]. Otherwise, an INVALID_ARGUMENT - // error is returned. - oneof max { - // Inclusive upper bound. - double maximum = 3; - - // Exclusive upper bound. - double exclusive_maximum = 4; - } -} - -// The price information of a [Product][google.cloud.retail.v2.Product]. -message PriceInfo { - // The price range of all - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. - message PriceRange { - // The inclusive - // [Product.pricing_info.price][google.cloud.retail.v2.PriceInfo.price] - // interval of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. - Interval price = 1; - - // The inclusive - // [Product.pricing_info.original_price][google.cloud.retail.v2.PriceInfo.original_price] - // internal of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. - Interval original_price = 2; - } - - // The 3-letter currency code defined in [ISO - // 4217](https://www.iso.org/iso-4217-currency-codes.html). - // - // If this field is an unrecognizable currency code, an INVALID_ARGUMENT - // error is returned. - // - // The [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s with the same - // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] - // must share the same - // [currency_code][google.cloud.retail.v2.PriceInfo.currency_code]. Otherwise, - // a FAILED_PRECONDITION error is returned. - string currency_code = 1; - - // Price of the product. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). Schema.org - // property [Offer.price](https://schema.org/price). - float price = 2; - - // Price of the product without any discount. If zero, by default set to be - // the [price][google.cloud.retail.v2.PriceInfo.price]. If set, - // [original_price][google.cloud.retail.v2.PriceInfo.original_price] should be - // greater than or equal to [price][google.cloud.retail.v2.PriceInfo.price], - // otherwise an INVALID_ARGUMENT error is thrown. - float original_price = 3; - - // The costs associated with the sale of a particular product. Used for gross - // profit reporting. - // - // * Profit = [price][google.cloud.retail.v2.PriceInfo.price] - - // [cost][google.cloud.retail.v2.PriceInfo.cost] - // - // Google Merchant Center property - // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). - float cost = 4; - - // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] - // starts to be effective. This can be set as a future timestamp, and the - // [price][google.cloud.retail.v2.PriceInfo.price] is only used for search - // after - // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. - // If so, the - // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be - // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] - // is used before - // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. - // - // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always - // effective because it will cause additional latency during search. - google.protobuf.Timestamp price_effective_time = 5; - - // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] - // stops to be effective. The [price][google.cloud.retail.v2.PriceInfo.price] - // is used for search before - // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. If - // this field is set, the - // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be - // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] - // is used after - // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. - // - // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always - // effective because it will cause additional latency during search. - google.protobuf.Timestamp price_expire_time = 6; - - // Output only. The price range of all the child - // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s grouped together on the - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]. Only populated for - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. - // Do not set this field in API requests. - PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The rating of a [Product][google.cloud.retail.v2.Product]. -message Rating { - // The total number of ratings. This value is independent of the value of - // [rating_histogram][google.cloud.retail.v2.Rating.rating_histogram]. - // - // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 rating_count = 1; - - // The average rating of the [Product][google.cloud.retail.v2.Product]. - // - // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is - // returned. - float average_rating = 2; - - // List of rating counts per rating value (index = rating - 1). The list is - // empty if there is no rating. If the list is non-empty, its size is - // always 5. Otherwise, an INVALID_ARGUMENT error is returned. - // - // For example, [41, 14, 13, 47, 303]. It means that the - // [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 - // ratings with 2 star, and so on. - repeated int32 rating_histogram = 3; -} - -// Information of an end user. -message UserInfo { - // Highly recommended for logged-in users. Unique identifier for logged-in - // user, such as a user name. Don't set for anonymous users. - // - // Always use a hashed value for this ID. - // - // Don't set the field to the same fixed ID for different users. This mixes - // the event history of those users together, which results in degraded - // model quality. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string user_id = 1; - - // The end user's IP address. This field is used to extract location - // information for personalization. - // - // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 - // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This should not be set when: - // - // * setting - // [SearchRequest.user_info][google.cloud.retail.v2.SearchRequest.user_info]. - // * using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] - // is set. - string ip_address = 2; - - // User agent as included in the HTTP header. Required for getting - // [SearchResponse.sponsored_results][google.cloud.retail.v2.SearchResponse.sponsored_results]. - // - // The field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This should not be set when using the client side event reporting with - // GTM or JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] - // is set. - string user_agent = 3; - - // True if the request is made directly from the end user, in which case the - // [ip_address][google.cloud.retail.v2.UserInfo.ip_address] and - // [user_agent][google.cloud.retail.v2.UserInfo.user_agent] can be populated - // from the HTTP request. This flag should be set only if the API request is - // made directly from the end user such as a mobile app (and not if a gateway - // or a server is processing and pushing the user events). - // - // This should not be set when using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent]. - bool direct_user_request = 4; -} - -// The inventory information at a place (e.g. a store) identified -// by a place ID. -message LocalInventory { - // The place ID for the current set of inventory information. - string place_id = 1; - - // Product price and cost information. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 2; - - // Additional local inventory attributes, for example, store name, promotion - // tags, etc. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * At most 30 attributes are allowed. - // * The key must be a UTF-8 encoded string with a length limit of 32 - // characters. - // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, - // key0LikeThis or KEY_1_LIKE_THIS. - // * The attribute values must be of the same type (text or number). - // * Only 1 value is allowed for each attribute. - // * For text values, the length limit is 256 UTF-8 characters. - // * The attribute does not support search. The `searchable` field should be - // unset or set to false. - // * The max summed total bytes of custom attribute keys and values per - // product is 5MiB. - map attributes = 3; - - // Input only. Supported fulfillment types. Valid fulfillment type values - // include commonly used types (such as pickup in store and same day - // delivery), and custom types. Customers have to map custom types to their - // display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string fulfillment_types = 4 - [(google.api.field_behavior) = INPUT_ONLY]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto deleted file mode 100644 index 68306218..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/completion_service.proto +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/import_config.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "CompletionServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Auto-completion service for retail. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service CompletionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Completes the specified prefix with keyword suggestions. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { - option (google.api.http) = { - get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" - }; - } - - // Bulk import of processed completion dataset. - // - // Request processing is asynchronous. Partial updating is not supported. - // - // The operation is successfully finished only after the imported suggestions - // are indexed successfully and ready for serving. The process takes hours. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc ImportCompletionData(ImportCompletionDataRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.ImportCompletionDataResponse" - metadata_type: "google.cloud.retail.v2.ImportMetadata" - }; - } -} - -// Auto-complete parameters. -message CompleteQueryRequest { - // Required. Catalog for which the completion is performed. - // - // Full resource name of catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The query used to generate suggestions. - // - // The maximum number of allowed characters is 255. - string query = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required field. A unique identifier for tracking visitors. For example, - // this could be implemented with an HTTP cookie, which should be able to - // uniquely identify a visitor on a single device. This unique identifier - // should not change if the visitor logs in or out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 7; - - // The language filters applied to the output suggestions. If set, it should - // contain the language of the query. If not set, suggestions are returned - // without considering language restrictions. This is the BCP-47 language - // code, such as "en-US" or "sr-Latn". For more information, see [Tags for - // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - // number of language codes is 3. - repeated string language_codes = 3; - - // The device type context for completion suggestions. - // It is useful to apply different suggestions on different device types, e.g. - // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - // types. - // - // Supported formats: - // - // * `UNKNOWN_DEVICE_TYPE` - // - // * `DESKTOP` - // - // * `MOBILE` - // - // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - string device_type = 4; - - // Determines which dataset to use for fetching completion. "user-data" will - // use the imported dataset through - // [CompletionService.ImportCompletionData][google.cloud.retail.v2.CompletionService.ImportCompletionData]. - // "cloud-retail" will use the dataset generated by cloud retail based on user - // events. If leave empty, it will use the "user-data". - // - // Current supported values: - // - // * user-data - // - // * cloud-retail: - // This option requires enabling auto-learning function first. See - // [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). - string dataset = 6; - - // Completion max suggestions. If left unset or set to 0, then will fallback - // to the configured value [CompletionConfig.max_suggestions][]. - // - // The maximum allowed max suggestions is 20. If it is set higher, it will be - // capped by 20. - int32 max_suggestions = 5; -} - -// Response of the auto-complete query. -message CompleteQueryResponse { - // Resource that represents completion results. - message CompletionResult { - // The suggestion for the query. - string suggestion = 1; - - // Custom attributes for the suggestion term. - // - // * For "user-data", the attributes are additional custom attributes - // ingested through BigQuery. - // - // * For "cloud-retail", the attributes are product attributes generated - // by Cloud Retail. This is an experimental feature. Contact Retail Search - // support team if you are interested in enabling it. - map attributes = 2; - } - - // Recent search of this user. - message RecentSearchResult { - // The recent search query. - string recent_search = 1; - } - - // Results of the matching suggestions. The result list is ordered and the - // first result is top suggestion. - repeated CompletionResult completion_results = 1; - - // A unique complete token. This should be included in the - // [UserEvent.completion_detail][google.cloud.retail.v2.UserEvent.completion_detail] - // for search events resulting from this completion, which enables accurate - // attribution of complete model performance. - string attribution_token = 2; - - // Matched recent searches of this user. The maximum number of recent searches - // is 10. This field is a restricted feature. Contact Retail Search support - // team if you are interested in enabling it. - // - // This feature is only available when - // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2.CompleteQueryRequest.visitor_id] - // field is set and [UserEvent][google.cloud.retail.v2.UserEvent] is imported. - // The recent searches satisfy the follow rules: - // - // * They are ordered from latest to oldest. - // - // * They are matched with - // [CompleteQueryRequest.query][google.cloud.retail.v2.CompleteQueryRequest.query] - // case insensitively. - // - // * They are transformed to lower cases. - // - // * They are UTF-8 safe. - // - // Recent searches are deduplicated. More recent searches will be reserved - // when duplication happens. - repeated RecentSearchResult recent_search_results = 3; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto deleted file mode 100644 index cadec119..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/import_config.proto +++ /dev/null @@ -1,401 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/product.proto"; -import "google/cloud/retail/v2/user_event.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "ImportConfigProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Google Cloud Storage location for input content. -// format. -message GcsSource { - // Required. Google Cloud Storage URIs to input files. URI can be up to - // 2000 characters long. URIs can match the full object path (for example, - // `gs://bucket/directory/object.json`) or a pattern matching one or more - // files, such as `gs://bucket/directory/*.json`. A request can - // contain at most 100 files, and each file can be up to 2 GB. See - // [Importing product - // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) - // for the expected file format and setup instructions. - repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] - // per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2.UserEvent] per line. - // * `user_event_ga360`: Using - // https://support.google.com/analytics/answer/3437719. - // - // Supported values for control imports: - // - // * 'control' (default): One JSON [Control][] per line. - // - // Supported values for catalog attribute imports: - // - // * 'catalog_attribute' (default): One CSV [CatalogAttribute][] per line. - string data_schema = 2; -} - -// BigQuery source import data from. -message BigQuerySource { - // BigQuery table partition info. Leave this empty if the BigQuery table - // is not partitioned. - oneof partition { - // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - google.type.Date partition_date = 6; - } - - // The project ID (can be project # or ID) that the BigQuery source is in with - // a length limit of 128 characters. If not specified, inherits the project - // ID from the parent request. - string project_id = 5; - - // Required. The BigQuery data set to copy the data from with a length limit - // of 1,024 characters. - string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The BigQuery table to copy the data from with a length limit of - // 1,024 characters. - string table_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Intermediate Cloud Storage directory used for the import with a length - // limit of 2,000 characters. Can be specified if one wants to have the - // BigQuery export to a specific Cloud Storage directory. - string gcs_staging_dir = 3; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] - // per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2.UserEvent] per line. - // * `user_event_ga360`: - // The schema is available here: - // https://support.google.com/analytics/answer/3437719. - // * `user_event_ga4`: This feature is in private preview. Please contact the - // support team for importing Google Analytics 4 events. - // The schema is available here: - // https://support.google.com/analytics/answer/7029846. - // - // Supported values for auto-completion imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - string data_schema = 4; -} - -// The inline source for the input config for ImportProducts method. -message ProductInlineSource { - // Required. A list of products to update/create. Each product must have a - // valid [Product.id][google.cloud.retail.v2.Product.id]. Recommended max of - // 100 items. - repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The inline source for the input config for ImportUserEvents method. -message UserEventInlineSource { - // Required. A list of user events to import. Recommended max of 10k items. - repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Configuration of destination for Import related errors. -message ImportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage prefix for import errors. This must be an empty, - // existing Cloud Storage directory. Import errors will be written to - // sharded files in this directory, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Request message for Import methods. -message ImportProductsRequest { - // Indicates how imported products are reconciled with the existing products - // created or imported before. - enum ReconciliationMode { - // Defaults to INCREMENTAL. - RECONCILIATION_MODE_UNSPECIFIED = 0; - - // Inserts new products or updates existing products. - INCREMENTAL = 1; - - // Calculates diff and replaces the entire product dataset. Existing - // products may be deleted if they are not present in the source location. - // - // Can only be set while using - // [BigQuerySource][google.cloud.retail.v2.BigQuerySource]. And the BigQuery - // dataset must be created in the data location "us (multiple regions in - // United States)", otherwise a PERMISSION_DENIED error is thrown. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - FULL = 2; - } - - // Required. - // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - // - // If no updateMask is specified, requires products.create permission. - // If updateMask is specified, requires products.update permission. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Deprecated. This field has no effect. - string request_id = 6 [deprecated = true]; - - // Required. The desired input location of the data. - ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. - ImportErrorsConfig errors_config = 3; - - // Indicates which fields in the provided imported 'products' to update. If - // not set, will by default update all fields. - google.protobuf.FieldMask update_mask = 4; - - // The mode of reconciliation between existing products and the products to be - // imported. Defaults to - // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. - ReconciliationMode reconciliation_mode = 5; - - // Full Pub/Sub topic name for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has - // to be within the same project as - // [ImportProductsRequest.parent][google.cloud.retail.v2.ImportProductsRequest.parent]. - // Make sure that both - // `cloud-retail-customer-data-access@system.gserviceaccount.com` and - // `service-@gcp-sa-retail.iam.gserviceaccount.com` - // have the `pubsub.topics.publish` IAM permission on the topic. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - string notification_pubsub_topic = 7; -} - -// Request message for the ImportUserEvents request. -message ImportUserEventsRequest { - // Required. `projects/1234/locations/global/catalogs/default_catalog` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - UserEventInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. Cannot be set - // for inline user event imports. - ImportErrorsConfig errors_config = 3; -} - -// Request message for ImportCompletionData methods. -message ImportCompletionDataRequest { - // Required. The catalog which the suggestions dataset belongs to. - // - // Format: `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - CompletionDataInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 3; -} - -// The input config source for products. -message ProductInputConfig { - // Required. The source of the input. - oneof source { - // The Inline source for the input content for products. - ProductInlineSource product_inline_source = 1; - - // Google Cloud Storage location for the input content. - GcsSource gcs_source = 2; - - // BigQuery input source. - BigQuerySource big_query_source = 3; - } -} - -// The input config source for user events. -message UserEventInputConfig { - // The source of the input. - oneof source { - // Required. The Inline source for the input content for UserEvents. - UserEventInlineSource user_event_inline_source = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Google Cloud Storage location for the input content. - GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. BigQuery input source. - BigQuerySource big_query_source = 3 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// The input config source for completion data. -message CompletionDataInputConfig { - // The source of the input. - // - // Supported - // [BigQuerySource.data_schema][google.cloud.retail.v2.BigQuerySource.data_schema] - // values for suggestions imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - oneof source { - // Required. BigQuery input source. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - BigQuerySource big_query_source = 1 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// Metadata related to the progress of the Import operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ImportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; - - // Deprecated. This field is never set. - string request_id = 5 [deprecated = true]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 6; -} - -// Response of the -// [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest]. If the -// long running operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ImportErrorsConfig errors_config = 2; -} - -// Response of the ImportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ImportErrorsConfig errors_config = 2; - - // Aggregated statistics of user event import status. - UserEventImportSummary import_summary = 3; -} - -// A summary of import result. The UserEventImportSummary summarizes -// the import status for user events. -message UserEventImportSummary { - // Count of user events imported with complete existing catalog information. - int64 joined_events_count = 1; - - // Count of user events imported, but with catalog information not found - // in the imported catalog. - int64 unjoined_events_count = 2; -} - -// Response of the -// [ImportCompletionDataRequest][google.cloud.retail.v2.ImportCompletionDataRequest]. -// If the long running operation is done, this message is returned by the -// google.longrunning.Operations.response field if the operation is successful. -message ImportCompletionDataResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto deleted file mode 100644 index f1f1b4e1..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/prediction_service.proto +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "PredictionServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for making recommendation prediction. -service PredictionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Makes a recommendation prediction. - rpc Predict(PredictRequest) returns (PredictResponse) { - option (google.api.http) = { - post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" - body: "*" - }; - } -} - -// Request message for Predict method. -message PredictRequest { - // Required. Full resource name of the format: - // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} - // The ID of the Recommendations AI placement. Before you can request - // predictions from your model, you must create at least one placement for it. - // For more information, see [Managing - // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - // - // The full list of available placements can be seen at - // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Context about the user, what they are looking at and what action - // they took to trigger the predict request. Note that this user event detail - // won't be ingested to userEvent logs. Thus, a separate userEvent write - // request is required for event logging. - // - // Don't set - // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id] or - // [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id] to the same - // fixed ID for different users. If you are trying to receive non-personalized - // recommendations (not recommended; this can negatively impact model - // performance), instead set - // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id] to a - // random unique ID and leave - // [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id] unset. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // Maximum number of results to return per page. Set this property - // to the number of prediction results needed. If zero, the service will - // choose a reasonable default. The maximum allowed value is 100. Values - // above 100 will be coerced to 100. - int32 page_size = 3; - - // The previous PredictResponse.next_page_token. - string page_token = 4; - - // Filter for restricting prediction results with a length limit of 5,000 - // characters. Accepts values for tags and the `filterOutOfStockItems` flag. - // - // * Tag expressions. Restricts predictions to products that match all of the - // specified tags. Boolean operators `OR` and `NOT` are supported if the - // expression is enclosed in parentheses, and must be separated from the - // tag values by a space. `-"tagA"` is also supported and is equivalent to - // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - // with a size limit of 1,000 characters. - // - // Note: "Recently viewed" models don't support tag filtering at the - // moment. - // - // * filterOutOfStockItems. Restricts predictions to products that do not - // have a - // stockState value of OUT_OF_STOCK. - // - // Examples: - // - // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - // * filterOutOfStockItems tag=(-"promotional") - // * filterOutOfStockItems - // - // If your filter blocks all prediction results, the API will return generic - // (unfiltered) popular products. If you only want results strictly matching - // the filters, set `strictFiltering` to True in `PredictRequest.params` to - // receive empty results instead. - // Note that the API will never return items with storageStatus of "EXPIRED" - // or "DELETED" regardless of filter choices. - string filter = 5; - - // Use validate only mode for this prediction query. If set to true, a - // dummy model will be used that returns arbitrary products. - // Note that the validate only mode should only be used for testing the API, - // or if the model is not ready. - bool validate_only = 6; - - // Additional domain specific parameters for the predictions. - // - // Allowed values: - // - // * `returnProduct`: Boolean. If set to true, the associated product - // object will be returned in the `results.metadata` field in the - // prediction response. - // * `returnScore`: Boolean. If set to true, the prediction 'score' - // corresponding to each returned product will be set in the - // `results.metadata` field in the prediction response. The given - // 'score' indicates the probability of an product being clicked/purchased - // given the user's context and history. - // * `strictFiltering`: Boolean. True by default. If set to false, the service - // will return generic (unfiltered) popular products instead of empty if - // your filter blocks all prediction results. - // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-price-reranking', 'low-price-reranking', - // 'medium-price-reranking', 'high-price-reranking'}. This gives - // request-level control and adjusts prediction results based on product - // price. - // * `diversityLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-diversity', 'low-diversity', - // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - // request-level control and adjusts prediction results based on product - // category. - map params = 7; - - // The labels applied to a resource must meet the following requirements: - // - // * Each resource can have multiple labels, up to a maximum of 64. - // * Each label must be a key-value pair. - // * Keys have a minimum length of 1 character and a maximum length of 63 - // characters and cannot be empty. Values can be empty and have a maximum - // length of 63 characters. - // * Keys and values can contain only lowercase letters, numeric characters, - // underscores, and dashes. All characters must use UTF-8 encoding, and - // international characters are allowed. - // * The key portion of a label must be unique. However, you can use the same - // key with multiple resources. - // * Keys must start with a lowercase letter or international character. - // - // See [Google Cloud - // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - // for more details. - map labels = 8; -} - -// Response message for predict method. -message PredictResponse { - // PredictionResult represents the recommendation prediction results. - message PredictionResult { - // ID of the recommended product - string id = 1; - - // Additional product metadata / annotations. - // - // Possible values: - // - // * `product`: JSON representation of the product. Is set if - // `returnProduct` is set to true in `PredictRequest.params`. - // * `score`: Prediction score in double value. Is set if - // `returnScore` is set to true in `PredictRequest.params`. - map metadata = 2; - } - - // A list of recommended products. The order represents the ranking (from the - // most relevant product to the least). - repeated PredictionResult results = 1; - - // A unique attribution token. This should be included in the - // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this - // recommendation, which enables accurate attribution of recommendation model - // performance. - string attribution_token = 2; - - // IDs of products in the request that were missing from the inventory. - repeated string missing_ids = 3; - - // True if the validateOnly property was set in the request. - bool validate_only = 4; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto deleted file mode 100644 index 43443295..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product.proto +++ /dev/null @@ -1,558 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/promotion.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; -option (google.api.resource_definition) = { - type: "retail.googleapis.com/Branch" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" -}; - -// Product captures all metadata information of items to be recommended or -// searched. -message Product { - option (google.api.resource) = { - type: "retail.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" - }; - - // The type of this product. - enum Type { - // Default value. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] - // if unset. - TYPE_UNSPECIFIED = 0; - - // The primary type. - // - // As the primary unit for predicting, indexing and search serving, a - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product] is grouped with multiple - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s. - PRIMARY = 1; - - // The variant type. - // - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s usually share some common - // attributes on the same - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s, but they have variant - // attributes like different colors, sizes and prices, etc. - VARIANT = 2; - - // The collection type. Collection products are bundled - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s or - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s that are sold together, such - // as a jewelry set with necklaces, earrings and rings, etc. - COLLECTION = 3; - } - - // Product availability. If this field is unspecified, the product is - // assumed to be in stock. - enum Availability { - // Default product availability. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK] - // if unset. - AVAILABILITY_UNSPECIFIED = 0; - - // Product in stock. - IN_STOCK = 1; - - // Product out of stock. - OUT_OF_STOCK = 2; - - // Product that is in pre-order state. - PREORDER = 3; - - // Product that is back-ordered (i.e. temporarily out of stock). - BACKORDER = 4; - } - - oneof expiration { - // The timestamp when this product becomes unavailable for - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - // - // If it is set, the [Product][google.cloud.retail.v2.Product] is not - // available for - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after - // [expire_time][google.cloud.retail.v2.Product.expire_time]. However, the - // product can still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // [expire_time][google.cloud.retail.v2.Product.expire_time] must be later - // than [available_time][google.cloud.retail.v2.Product.available_time] and - // [publish_time][google.cloud.retail.v2.Product.publish_time], otherwise an - // INVALID_ARGUMENT error is thrown. - // - // Corresponding properties: Google Merchant Center property - // [expiration_date](https://support.google.com/merchants/answer/6324499). - google.protobuf.Timestamp expire_time = 16; - - // Input only. The TTL (time to live) of the product. - // - // If it is set, it must be a non-negative value, and - // [expire_time][google.cloud.retail.v2.Product.expire_time] is set as - // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. The - // derived [expire_time][google.cloud.retail.v2.Product.expire_time] is - // returned in the output and [ttl][google.cloud.retail.v2.Product.ttl] is - // left blank when retrieving the [Product][google.cloud.retail.v2.Product]. - // - // If it is set, the product is not available for - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after - // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. - // However, the product can still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - google.protobuf.Duration ttl = 17 - [(google.api.field_behavior) = INPUT_ONLY]; - } - - // Immutable. Full resource name of the product, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. [Product][google.cloud.retail.v2.Product] identifier, which is - // the final component of [name][google.cloud.retail.v2.Product.name]. For - // example, this field is "id_1", if - // [name][google.cloud.retail.v2.Product.name] is - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [id](https://support.google.com/merchants/answer/6324405). Schema.org - // property [Product.sku](https://schema.org/sku). - string id = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The type of the product. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] - // if unset. - Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; - - // Variant group identifier. Must be an - // [id][google.cloud.retail.v2.Product.id], with the same parent branch with - // this product. Otherwise, an error is thrown. - // - // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s, this field can only be empty or - // set to the same value as [id][google.cloud.retail.v2.Product.id]. - // - // For VARIANT [Product][google.cloud.retail.v2.Product]s, this field cannot - // be empty. A maximum of 2,000 products are allowed to share the same - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]. Otherwise, an INVALID_ARGUMENT - // error is returned. - // - // Corresponding properties: Google Merchant Center property - // [item_group_id](https://support.google.com/merchants/answer/6324507). - // Schema.org property - // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). - string primary_product_id = 4; - - // The [id][google.cloud.retail.v2.Product.id] of the collection members when - // [type][google.cloud.retail.v2.Product.type] is - // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]. - // - // Non-existent product ids are allowed. - // The [type][google.cloud.retail.v2.Product.type] of the members must be - // either [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] or - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] otherwise and - // INVALID_ARGUMENT error is thrown. Should not set it for other types. A - // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is - // return. - repeated string collection_member_ids = 5; - - // The Global Trade Item Number (GTIN) of the product. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Corresponding properties: Google Merchant Center property - // [gtin](https://support.google.com/merchants/answer/6324461). - // Schema.org property - // [Product.isbn](https://schema.org/isbn), - // [Product.gtin8](https://schema.org/gtin8), - // [Product.gtin12](https://schema.org/gtin12), - // [Product.gtin13](https://schema.org/gtin13), or - // [Product.gtin14](https://schema.org/gtin14). - // - // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. - string gtin = 6; - - // Product categories. This field is repeated for supporting one product - // belonging to several parallel categories. Strongly recommended using the - // full path for better search / recommendation quality. - // - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // For example, if a shoes product belongs to both - // ["Shoes & Accessories" -> "Shoes"] and - // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be - // represented as: - // - // "categories": [ - // "Shoes & Accessories > Shoes", - // "Sports & Fitness > Athletic Clothing > Shoes" - // ] - // - // Must be set for [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product] otherwise an INVALID_ARGUMENT - // error is returned. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2.Product]. Empty values are not allowed. - // Each value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [google_product_category][mc_google_product_category]. Schema.org property - // [Product.category] (https://schema.org/category). - // - // [mc_google_product_category]: - // https://support.google.com/merchants/answer/6324436 - repeated string categories = 7; - - // Required. Product title. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [title](https://support.google.com/merchants/answer/6324415). Schema.org - // property [Product.name](https://schema.org/name). - string title = 8 [(google.api.field_behavior) = REQUIRED]; - - // The brands of the product. - // - // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded - // string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [brand](https://support.google.com/merchants/answer/6324351). Schema.org - // property [Product.brand](https://schema.org/brand). - repeated string brands = 9; - - // Product description. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [description](https://support.google.com/merchants/answer/6324468). - // Schema.org property [Product.description](https://schema.org/description). - string description = 10; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // - // For product prediction, this field is ignored and the model automatically - // detects the text language. The [Product][google.cloud.retail.v2.Product] - // can include text in different languages, but duplicating - // [Product][google.cloud.retail.v2.Product]s to provide text in multiple - // languages can result in degraded model performance. - // - // For product search this field is in use. It defaults to "en-US" if unset. - string language_code = 11; - - // Highly encouraged. Extra product attributes to be included. For example, - // for products, this could include the store name, vendor, style, color, etc. - // These are very strong signals for recommendation model, thus we highly - // recommend providing the attributes here. - // - // Features that can take on one of a limited number of possible values. Two - // types of features can be set are: - // - // Textual features. some examples would be the brand/maker of a product, or - // country of a customer. Numerical features. Some examples would be the - // height/weight of a product, or age of a customer. - // - // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, - // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} - // }`. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * Max entries count: 200. - // * The key must be a UTF-8 encoded string with a length limit of 128 - // characters. - // * For indexable attribute, the key must match the pattern: - // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or - // `KEY_1_LIKE_THIS`. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a non-empty UTF-8 encoded string with a - // length limit of 256 characters. - // * For number attributes, at most 400 values are allowed. - map attributes = 12; - - // Custom tags associated with the product. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2.Product]. This value must be a UTF-8 - // encoded string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This tag can be used for filtering recommendation results by passing the - // tag as part of the - // [PredictRequest.filter][google.cloud.retail.v2.PredictRequest.filter]. - // - // Corresponding properties: Google Merchant Center property - // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). - repeated string tags = 13; - - // Product price and cost information. - // - // Corresponding properties: Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 14; - - // The rating of this product. - Rating rating = 15; - - // The timestamp when this [Product][google.cloud.retail.v2.Product] becomes - // available for - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - google.protobuf.Timestamp available_time = 18; - - // The online availability of the [Product][google.cloud.retail.v2.Product]. - // Default to - // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK]. - // - // Corresponding properties: Google Merchant Center property - // [availability](https://support.google.com/merchants/answer/6324448). - // Schema.org property [Offer.availability](https://schema.org/availability). - Availability availability = 19; - - // The available quantity of the item. - google.protobuf.Int32Value available_quantity = 20; - - // Fulfillment information, such as the store IDs for in-store pickup or - // region IDs for different shipping methods. - // - // All the elements must have distinct - // [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type]. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated FulfillmentInfo fulfillment_info = 21; - - // Canonical URL directly linking to the product detail page. - // - // It is strongly recommended to provide a valid uri for the product, - // otherwise the service performance could be significantly degraded. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [link](https://support.google.com/merchants/answer/6324416). Schema.org - // property [Offer.url](https://schema.org/url). - string uri = 22; - - // Product images for the product. We highly recommend putting the main - // image first. - // - // A maximum of 300 images are allowed. - // - // Corresponding properties: Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - repeated Image images = 23; - - // The target group associated with a given audience (e.g. male, veterans, - // car owners, musicians, etc.) of the product. - Audience audience = 24; - - // The color of the product. - // - // Corresponding properties: Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - ColorInfo color_info = 25; - - // The size of the product. To represent different size systems or size types, - // consider using this format: [[[size_system:]size_type:]size_value]. - // - // For example, in "US:MENS:M", "US" represents size system; "MENS" represents - // size type; "M" represents size value. In "GIRLS:27", size system is empty; - // "GIRLS" represents size type; "27" represents size value. In "32 inches", - // both size system and size type are empty, while size value is "32 inches". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [size](https://support.google.com/merchants/answer/6324492), - // [size_type](https://support.google.com/merchants/answer/6324497), and - // [size_system](https://support.google.com/merchants/answer/6324502). - // Schema.org property [Product.size](https://schema.org/size). - repeated string sizes = 26; - - // The material of the product. For example, "leather", "wooden". - // - // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 200 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [material](https://support.google.com/merchants/answer/6324410). Schema.org - // property [Product.material](https://schema.org/material). - repeated string materials = 27; - - // The pattern or graphic print of the product. For example, "striped", "polka - // dot", "paisley". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org - // property [Product.pattern](https://schema.org/pattern). - repeated string patterns = 28; - - // The condition of the product. Strongly encouraged to use the standard - // values: "new", "refurbished", "used". - // - // A maximum of 1 value is allowed per - // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [condition](https://support.google.com/merchants/answer/6324469). - // Schema.org property - // [Offer.itemCondition](https://schema.org/itemCondition). - repeated string conditions = 29; - - // The promotions applied to the product. A maximum of 10 values are allowed - // per [Product][google.cloud.retail.v2.Product]. Only - // [Promotion.promotion_id][google.cloud.retail.v2.Promotion.promotion_id] - // will be used, other fields will be ignored if set. - repeated Promotion promotions = 34; - - // The timestamp when the product is published by the retailer for the first - // time, which indicates the freshness of the products. Note that this field - // is different from - // [available_time][google.cloud.retail.v2.Product.available_time], given it - // purely describes product freshness regardless of when it is available on - // search and recommendation. - google.protobuf.Timestamp publish_time = 33; - - // Indicates which fields in the [Product][google.cloud.retail.v2.Product]s - // are returned in [SearchResponse][google.cloud.retail.v2.SearchResponse]. - // - // Supported fields for all [type][google.cloud.retail.v2.Product.type]s: - // - // * [audience][google.cloud.retail.v2.Product.audience] - // * [availability][google.cloud.retail.v2.Product.availability] - // * [brands][google.cloud.retail.v2.Product.brands] - // * [color_info][google.cloud.retail.v2.Product.color_info] - // * [conditions][google.cloud.retail.v2.Product.conditions] - // * [gtin][google.cloud.retail.v2.Product.gtin] - // * [materials][google.cloud.retail.v2.Product.materials] - // * [name][google.cloud.retail.v2.Product.name] - // * [patterns][google.cloud.retail.v2.Product.patterns] - // * [price_info][google.cloud.retail.v2.Product.price_info] - // * [rating][google.cloud.retail.v2.Product.rating] - // * [sizes][google.cloud.retail.v2.Product.sizes] - // * [title][google.cloud.retail.v2.Product.title] - // * [uri][google.cloud.retail.v2.Product.uri] - // - // Supported fields only for - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]: - // - // * [categories][google.cloud.retail.v2.Product.categories] - // * [description][google.cloud.retail.v2.Product.description] - // * [images][google.cloud.retail.v2.Product.images] - // - // Supported fields only for - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]: - // - // * Only the first image in [images][google.cloud.retail.v2.Product.images] - // - // To mark [attributes][google.cloud.retail.v2.Product.attributes] as - // retrievable, include paths of the form "attributes.key" where "key" is the - // key of a custom attribute, as specified in - // [attributes][google.cloud.retail.v2.Product.attributes]. - // - // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], the - // following fields are always returned in - // [SearchResponse][google.cloud.retail.v2.SearchResponse] by default: - // - // * [name][google.cloud.retail.v2.Product.name] - // - // For [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT], the - // following fields are always returned in by default: - // - // * [name][google.cloud.retail.v2.Product.name] - // * [color_info][google.cloud.retail.v2.Product.color_info] - // - // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Note: Returning more fields in - // [SearchResponse][google.cloud.retail.v2.SearchResponse] can increase - // response payload size and serving latency. - google.protobuf.FieldMask retrievable_fields = 30; - - // Output only. Product variants grouped together on primary product which - // share similar product attributes. It's automatically grouped by - // [primary_product_id][google.cloud.retail.v2.Product.primary_product_id] for - // all the product variants. Only populated for - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. - // Do not set this field in API requests. - repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto deleted file mode 100644 index ba8d8d18..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/product_service.proto +++ /dev/null @@ -1,838 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/import_config.proto"; -import "google/cloud/retail/v2/product.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for ingesting [Product][google.cloud.retail.v2.Product] information -// of the customer's website. -service ProductService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a [Product][google.cloud.retail.v2.Product]. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Gets a [Product][google.cloud.retail.v2.Product]. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Product][google.cloud.retail.v2.Product]s. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a [Product][google.cloud.retail.v2.Product]. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v2/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Deletes a [Product][google.cloud.retail.v2.Product]. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. - // - // Request processing may be synchronous. - // Non-existing items are created. - // - // Note that it is possible for a subset of the - // [Product][google.cloud.retail.v2.Product]s to be successfully updated. - rpc ImportProducts(ImportProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.ImportProductsResponse" - metadata_type: "google.cloud.retail.v2.ImportMetadata" - }; - } - - // Updates inventory information for a - // [Product][google.cloud.retail.v2.Product] while respecting the last update - // timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, updates are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // When inventory is updated with - // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and - // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the - // specified inventory field value(s) will overwrite any existing value(s) - // while ignoring the last update time for this field. Furthermore, the last - // update time for the specified inventory fields will be overwritten to the - // time of the - // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or - // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] - // request. - // - // If no inventory fields are set in - // [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], - // then any pre-existing inventory information for this product will be used. - // - // If no inventory fields are set in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], - // then any existing inventory information will be preserved. - // - // Pre-existing inventory information can only be updated with - // [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], - // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], - // and - // [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" - body: "*" - }; - option (google.api.method_signature) = "inventory,set_mask"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.SetInventoryResponse" - metadata_type: "google.cloud.retail.v2.SetInventoryMetadata" - }; - } - - // Incrementally adds place IDs to - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the added place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.AddFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2.AddFulfillmentPlacesMetadata" - }; - } - - // Incrementally removes place IDs from a - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the removed place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata" - }; - } - - // Updates local inventory information for a - // [Product][google.cloud.retail.v2.Product] at a list of places, while - // respecting the last update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2.Product] to exist before updating - // inventory information. If the request is valid, the update will be enqueued - // and processed downstream. As a consequence, when a response is returned, - // updates are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // Local inventory information can only be modified using this method. - // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and - // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no - // effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddLocalInventories(AddLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.AddLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2.AddLocalInventoriesMetadata" - }; - } - - // Remove local inventory information for a - // [Product][google.cloud.retail.v2.Product] at a list of places at a removal - // timestamp. - // - // This process is asynchronous. If the request is valid, the removal will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, removals are not immediately manifested in the - // [Product][google.cloud.retail.v2.Product] queried by - // [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // Local inventory information can only be removed using this method. - // [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and - // [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no - // effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.RemoveLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2.RemoveLocalInventoriesMetadata" - }; - } -} - -// Request message for [CreateProduct][] method. -message CreateProductRequest { - // Required. The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Required. The [Product][google.cloud.retail.v2.Product] to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the [Product][google.cloud.retail.v2.Product], - // which will become the final component of the - // [Product.name][google.cloud.retail.v2.Product.name]. - // - // If the caller does not have permission to create the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // This field must be unique among all - // [Product][google.cloud.retail.v2.Product]s with the same - // [parent][google.cloud.retail.v2.CreateProductRequest.parent]. Otherwise, an - // ALREADY_EXISTS error is returned. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string product_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [GetProduct][] method. -message GetProductRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // If the requested [Product][google.cloud.retail.v2.Product] does not exist, - // a NOT_FOUND error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for [UpdateProduct][] method. -message UpdateProductRequest { - // Required. The product to update/create. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2.Product] to update does not exist - // and - // [allow_missing][google.cloud.retail.v2.UpdateProductRequest.allow_missing] - // is not set, a NOT_FOUND error is returned. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Product][google.cloud.retail.v2.Product] to update. The immutable and - // output only fields are NOT supported. If not set, all supported fields (the - // fields that are neither immutable nor output only) are updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - // - // The attribute key can be updated by setting the mask path as - // "attributes.${key_name}". If a key name is present in the mask but not in - // the patching product from the request, this key will be deleted after the - // update. - google.protobuf.FieldMask update_mask = 2; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, a new [Product][google.cloud.retail.v2.Product] will be created. In - // this situation, `update_mask` is ignored. - bool allow_missing = 3; -} - -// Request message for [DeleteProduct][] method. -message DeleteProductRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to delete the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2.Product] to delete does not exist, - // a NOT_FOUND error is returned. - // - // The [Product][google.cloud.retail.v2.Product] to delete can neither be a - // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2.Product] member nor a - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product] with more than one - // [variants][google.cloud.retail.v2.Product.Type.VARIANT]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // All inventory information for the named - // [Product][google.cloud.retail.v2.Product] will be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for -// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] -// method. -message ListProductsRequest { - // Required. The parent branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use - // `default_branch` as the branch ID, to list products under the default - // branch. - // - // If the caller does not have permission to list - // [Product][google.cloud.retail.v2.Product]s under this branch, regardless of - // whether or not this branch exists, a PERMISSION_DENIED error is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If - // unspecified, defaults to 100. The maximum allowed value is 1000. Values - // above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT error is returned. - int32 page_size = 2; - - // A page token - // [ListProductsResponse.next_page_token][google.cloud.retail.v2.ListProductsResponse.next_page_token], - // received from a previous - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; - - // A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2.ListProductsRequest.filter] is unset. - // * List [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s sharing the same - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product]. For example: - // `primary_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2.Product]s bundled in a - // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2.Product]. - // For example: - // `collection_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2.Product]s with a partibular type. - // For example: - // `type = "PRIMARY"` - // `type = "VARIANT"` - // `type = "COLLECTION"` - // - // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - // - // If the specified - // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2.Product] or - // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2.Product] does not exist, a NOT_FOUND error - // is returned. - string filter = 4; - - // The fields of [Product][google.cloud.retail.v2.Product] to return in the - // responses. If not set or empty, the following fields are returned: - // - // * [Product.name][google.cloud.retail.v2.Product.name] - // * [Product.id][google.cloud.retail.v2.Product.id] - // * [Product.title][google.cloud.retail.v2.Product.title] - // * [Product.uri][google.cloud.retail.v2.Product.uri] - // * [Product.images][google.cloud.retail.v2.Product.images] - // * [Product.price_info][google.cloud.retail.v2.Product.price_info] - // * [Product.brands][google.cloud.retail.v2.Product.brands] - // - // If "*" is provided, all fields are returned. - // [Product.name][google.cloud.retail.v2.Product.name] is always returned no - // matter what mask is set. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask read_mask = 5; -} - -// Response message for -// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] -// method. -message ListProductsResponse { - // The [Product][google.cloud.retail.v2.Product]s. - repeated Product products = 1; - - // A token that can be sent as - // [ListProductsRequest.page_token][google.cloud.retail.v2.ListProductsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request message for [SetInventory][] method. -message SetInventoryRequest { - // Required. The inventory information to update. The allowable fields to - // update are: - // * [Product.price_info][google.cloud.retail.v2.Product.price_info] - // * [Product.availability][google.cloud.retail.v2.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] - // The updated inventory fields must be specified in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask]. - // - // If [SetInventoryRequest.inventory.name][] is empty or invalid, an - // INVALID_ARGUMENT error is returned. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2.Product] named in - // [Product.name][google.cloud.retail.v2.Product.name], regardless of whether - // or not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2.Product] to update does not have - // existing inventory information, the provided inventory information will be - // inserted. - // - // If the [Product][google.cloud.retail.v2.Product] to update has existing - // inventory information, the provided inventory information will be merged - // while respecting the last update time for each inventory field, using the - // provided or default value for - // [SetInventoryRequest.set_time][google.cloud.retail.v2.SetInventoryRequest.set_time]. - // - // The caller can replace place IDs for a subset of fulfillment types in the - // following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types and corresponding place IDs - // to update in [SetInventoryRequest.inventory.fulfillment_info][] - // - // The caller can clear all place IDs from a subset of fulfillment types in - // the following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types to clear in - // [SetInventoryRequest.inventory.fulfillment_info][] - // * Checks that only the desired fulfillment info types have empty - // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] - // - // The last update time is recorded for the following inventory fields: - // * [Product.price_info][google.cloud.retail.v2.Product.price_info] - // * [Product.availability][google.cloud.retail.v2.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] - // - // If a full overwrite of inventory information while ignoring timestamps is - // needed, [UpdateProduct][] should be invoked instead. - Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided - // [Product][google.cloud.retail.v2.Product] to update. - // - // At least one field must be provided. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask set_mask = 2; - - // The time when the request is issued, used to prevent - // out-of-order updates on inventory fields with the last update time - // recorded. If not provided, the internal system time will be used. - google.protobuf.Timestamp set_time = 3; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] with name - // [Product.name][google.cloud.retail.v2.Product.name] is not found, the - // inventory update will still be processed and retained for at most 1 day - // until the [Product][google.cloud.retail.v2.Product] is created. If set to - // false, a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 4; -} - -// Metadata related to the progress of the SetInventory operation. -// Currently empty because there is no meaningful metadata populated from the -// [SetInventory][] method. -message SetInventoryMetadata {} - -// Response of the SetInventoryRequest. Currently empty because -// there is no meaningful response populated from the [SetInventory][] -// method. -message SetInventoryResponse {} - -// Request message for -// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] -// method. -message AddFulfillmentPlacesRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type], such as - // the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery" to be added for this - // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type]. Duplicate - // IDs will be automatically ignored. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // If the total number of place IDs exceeds 2000 for this - // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type] after - // adding, then the update will be rejected. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, the fulfillment information will still be processed and retained for - // at most 1 day and processed once the - // [Product][google.cloud.retail.v2.Product] is created. If set to false, a - // NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the AddFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] -// method. -message AddFulfillmentPlacesMetadata {} - -// Response of the AddFulfillmentPlacesRequest. Currently empty because -// there is no meaningful response populated from the -// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] -// method. -message AddFulfillmentPlacesResponse {} - -// Request message for -// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] -// method. -message AddLocalInventoriesRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of inventory information at difference places. Each place - // is identified by its place ID. At most 3000 inventories are allowed per - // request. - repeated LocalInventory local_inventories = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided list of - // [LocalInventory][google.cloud.retail.v2.LocalInventory] to update. The - // field is updated to the provided value. - // - // If a field is set while the place does not have a previous local inventory, - // the local inventory at that store is created. - // - // If a field is set while the value of that field is not provided, the - // original field value, if it exists, is deleted. - // - // If the mask is not set or set with empty paths, all inventory fields will - // be updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask add_mask = 4; - - // The time when the inventory updates are issued. Used to prevent - // out-of-order updates on local inventory fields. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, the local inventory will still be processed and retained for at most - // 1 day and processed once the [Product][google.cloud.retail.v2.Product] is - // created. If set to false, a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 6; -} - -// Metadata related to the progress of the AddLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] -// method. -message AddLocalInventoriesMetadata {} - -// Response of the -// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] -// API. Currently empty because there is no meaningful response populated from -// the -// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] -// method. -message AddLocalInventoriesResponse {} - -// Request message for [RemoveLocalInventories][] method. -message RemoveLocalInventoriesRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of place IDs to have their inventory deleted. - // At most 3000 place IDs are allowed per request. - repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; - - // The time when the inventory deletions are issued. Used to prevent - // out-of-order updates and deletions on local inventory fields. If not - // provided, the internal system time will be used. - google.protobuf.Timestamp remove_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, the local inventory removal request will still be processed and - // retained for at most 1 day and processed once the - // [Product][google.cloud.retail.v2.Product] is created. If set to false, a - // NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 3; -} - -// Metadata related to the progress of the RemoveLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveLocalInventories][] method. -message RemoveLocalInventoriesMetadata {} - -// Response of the [RemoveLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [RemoveLocalInventories][] -// method. -message RemoveLocalInventoriesResponse {} - -// Request message for [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesRequest { - // Required. Full resource name of [Product][google.cloud.retail.v2.Product], - // such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2.Product], regardless of whether or not it - // exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to - // [Product.fulfillment_info.type][google.cloud.retail.v2.FulfillmentInfo.type]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type], such as - // the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery", to be removed for this - // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type]. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp remove_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2.Product] is not - // found, the fulfillment information will still be processed and retained for - // at most 1 day and processed once the - // [Product][google.cloud.retail.v2.Product] is created. If set to false, a - // NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the RemoveFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesMetadata {} - -// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there -// is no meaningful response populated from the [RemoveFulfillmentPlaces][] -// method. -message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto deleted file mode 100644 index 9ba32347..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/promotion.proto +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "PromotionProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Promotion information. -message Promotion { - // ID of the promotion. For example, "free gift". - // - // The value must be a UTF-8 encoded string with a length limit of 128 - // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, - // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Google Merchant Center property - // [promotion](https://support.google.com/merchants/answer/7050148). - string promotion_id = 1; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto deleted file mode 100644 index cb510745..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/purge_config.proto +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "PurgeConfigProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Metadata related to the progress of the Purge operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeMetadata {} - -// Request message for PurgeUserEvents method. -message PurgeUserEventsRequest { - // Required. The resource name of the catalog under which the events are - // created. The format is - // `projects/${projectId}/locations/global/catalogs/${catalogId}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The filter string to specify the events to be deleted with a - // length limit of 5,000 characters. Empty string filter is not allowed. The - // eligible fields for filtering are: - // - // * `eventType`: Double quoted - // [UserEvent.event_type][google.cloud.retail.v2.UserEvent.event_type] string. - // * `eventTime`: in ISO 8601 "zulu" format. - // * `visitorId`: Double quoted string. Specifying this will delete all - // events associated with a visitor. - // * `userId`: Double quoted string. Specifying this will delete all events - // associated with a user. - // - // Examples: - // - // * Deleting all events in a time range: - // `eventTime > "2012-04-23T18:25:43.511Z" - // eventTime < "2012-04-23T18:30:43.511Z"` - // * Deleting specific eventType in time range: - // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - // * Deleting all events for a specific visitor: - // `visitorId = "visitor1024"` - // - // The filtering fields are assumed to have an implicit AND. - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually perform the purge. - // If `force` is set to false, the method will return the expected purge count - // without deleting any user events. - bool force = 3; -} - -// Response of the PurgeUserEventsRequest. If the long running operation is -// successfully done, then this message is returned by the -// google.longrunning.Operations.response field. -message PurgeUserEventsResponse { - // The total count of events purged as a result of the operation. - int64 purged_events_count = 1; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto deleted file mode 100644 index 82242742..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/search_service.proto +++ /dev/null @@ -1,854 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/product.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "SearchServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for search. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service SearchService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Performs a search. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc Search(SearchRequest) returns (SearchResponse) { - option (google.api.http) = { - post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" - body: "*" - }; - } -} - -// Request message for -// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. -message SearchRequest { - // A facet specification to perform faceted search. - message FacetSpec { - // Specifies how a facet is computed. - message FacetKey { - // Required. Supported textual and numerical facet keys in - // [Product][google.cloud.retail.v2.Product] object, over which the facet - // values are computed. Facet key is case-sensitive. - // - // Allowed facet keys when - // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] - // is not specified: - // - // * textual_field = - // * "brands" - // * "categories" - // * "genders" - // * "ageGroups" - // * "availability" - // * "colorFamilies" - // * "colors" - // * "sizes" - // * "materials" - // * "patterns" - // * "conditions" - // * "attributes.key" - // * "pickupInStore" - // * "shipToStore" - // * "sameDayDelivery" - // * "nextDayDelivery" - // * "customFulfillment1" - // * "customFulfillment2" - // * "customFulfillment3" - // * "customFulfillment4" - // * "customFulfillment5" - // * "inventory(place_id,attributes.key)" - // - // * numerical_field = - // * "price" - // * "discount" - // * "rating" - // * "ratingCount" - // * "attributes.key" - // * "inventory(place_id,price)" - // * "inventory(place_id,original_price)" - // * "inventory(place_id,attributes.key)" - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Set only if values should be bucketized into intervals. Must be set - // for facets with numerical values. Must not be set for facet with text - // values. Maximum number of intervals is 30. - repeated Interval intervals = 2; - - // Only get facet for the given restricted values. For example, when using - // "pickupInStore" as key and set restricted values to - // ["store123", "store456"], only facets for "store123" and "store456" are - // returned. Only supported on predefined textual fields, custom textual - // attributes and fulfillments. Maximum is 20. - // - // Must be set for the fulfillment facet keys: - // - // * pickupInStore - // - // * shipToStore - // - // * sameDayDelivery - // - // * nextDayDelivery - // - // * customFulfillment1 - // - // * customFulfillment2 - // - // * customFulfillment3 - // - // * customFulfillment4 - // - // * customFulfillment5 - repeated string restricted_values = 3; - - // Only get facet values that start with the given string prefix. For - // example, suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the - // "categories" facet will give only "Women > Shoe" and "Women > Dress". - // Only supported on textual fields. Maximum is 10. - repeated string prefixes = 8; - - // Only get facet values that contains the given strings. For example, - // suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the - // "categories" facet will give only "Women > Shoe" and "Men > Shoe". - // Only supported on textual fields. Maximum is 10. - repeated string contains = 9; - - // The order in which [Facet.values][] are returned. - // - // Allowed values are: - // - // * "count desc", which means order by [Facet.FacetValue.count][] - // descending. - // - // * "value desc", which means order by [Facet.FacetValue.value][] - // descending. - // Only applies to textual facets. - // - // If not set, textual values are sorted in [natural - // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical - // intervals are sorted in the order given by - // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.intervals]; - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // are sorted in the order given by - // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.restricted_values]. - string order_by = 4; - - // The query that is used to compute facet for the given facet key. - // When provided, it will override the default behavior of facet - // computation. The query syntax is the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for - // detail syntax and limitations. Notice that there is no limitation on - // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] - // when query is specified. - // - // In the response, [FacetValue.value][] will be always "1" and - // [FacetValue.count][] will be the number of results that matches the - // query. - // - // For example, you can set a customized facet for "shipToStore", - // where - // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] - // is "customizedShipToStore", and - // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] - // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". - // Then the facet will count the products that are both in stock and ship - // to store "123". - string query = 5; - } - - // Required. The facet key specification. - FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum of facet values that should be returned for this facet. If - // unspecified, defaults to 20. The maximum allowed value is 300. Values - // above 300 will be coerced to 300. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 limit = 2; - - // List of keys to exclude when faceting. - // - // - // By default, - // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] - // is not excluded from the filter unless it is listed in this field. - // - // Listing a facet key in this field allows its values to appear as facet - // results, even when they are filtered out of search results. Using this - // field does not affect what search results are returned. - // - // For example, suppose there are 100 products with the color facet "Red" - // and 200 products with the color facet "Blue". A query containing the - // filter "colorFamilies:ANY("Red")" and having "colorFamilies" as - // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] - // would by default return only "Red" products in the search results, and - // also return "Red" with count 100 as the only color facet. Although there - // are also blue products available, "Blue" would not be shown as an - // available facet value. - // - // If "colorFamilies" is listed in "excludedFilterKeys", then the query - // returns the facet values "Red" with count 100 and "Blue" with count - // 200, because the "colorFamilies" key is now excluded from the filter. - // Because this field doesn't affect search results, the search results - // are still correctly filtered to return only "Red" products. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated string excluded_filter_keys = 3; - - // Enables dynamic position for this facet. If set to true, the position of - // this facet among all facets in the response is determined by Google - // Retail Search. It will be ordered together with dynamic facets if dynamic - // facets is enabled. If set to false, the position of this facet in the - // response will be the same as in the request, and it will be ranked before - // the facets with dynamic position enable and all dynamic facets. - // - // For example, you may always want to have rating facet returned in - // the response, but it's not necessarily to always display the rating facet - // at the top. In that case, you can set enable_dynamic_position to true so - // that the position of rating facet in response will be determined by - // Google Retail Search. - // - // Another example, assuming you have the following facets in the request: - // - // * "rating", enable_dynamic_position = true - // - // * "price", enable_dynamic_position = false - // - // * "brands", enable_dynamic_position = false - // - // And also you have a dynamic facets enable, which will generate a facet - // 'gender'. Then the final order of the facets in the response can be - // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", - // "rating") depends on how Google Retail Search orders "gender" and - // "rating" facets. However, notice that "price" and "brands" will always be - // ranked at 1st and 2nd position since their enable_dynamic_position are - // false. - bool enable_dynamic_position = 4; - } - - // The specifications of dynamically generated facets. - message DynamicFacetSpec { - // Enum to control DynamicFacet mode - enum Mode { - // Default value. - MODE_UNSPECIFIED = 0; - - // Disable Dynamic Facet. - DISABLED = 1; - - // Automatic mode built by Google Retail Search. - ENABLED = 2; - } - - // Mode of the DynamicFacet feature. - // Defaults to - // [Mode.DISABLED][google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode.DISABLED] - // if it's unset. - Mode mode = 1; - } - - // Boost specification to boost certain items. - message BoostSpec { - // Boost applies to products which match a condition. - message ConditionBoostSpec { - // An expression which specifies a boost condition. The syntax and - // supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for - // detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue": - // * (id: ANY("product_1", "product_2")) AND (colorFamilies: - // ANY("Red","Blue")) - string condition = 1; - - // Strength of the condition boost, which should be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 2; - } - - // Condition boost specifications. If a product matches multiple conditions - // in the specifictions, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 20. - repeated ConditionBoostSpec condition_boost_specs = 1; - - // Whether to skip boostspec validation. If this field is set to true, - // invalid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] - // will be ignored and valid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] - // will still be applied. - optional bool skip_boost_spec_validation = 2; - } - - // Specification to determine under which conditions query expansion should - // occur. - message QueryExpansionSpec { - // Enum describing under which condition query expansion should occur. - enum Condition { - // Unspecified query expansion condition. This defaults to - // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - CONDITION_UNSPECIFIED = 0; - - // Disabled query expansion. Only the exact search query is used, even if - // [SearchResponse.total_size][google.cloud.retail.v2.SearchResponse.total_size] - // is zero. - DISABLED = 1; - - // Automatic query expansion built by Google Retail Search. - AUTO = 3; - } - - // The condition under which query expansion should occur. Default to - // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - Condition condition = 1; - - // Whether to pin unexpanded results. If this field is set to true, - // unexpanded products are always at the top of the search results, followed - // by the expanded results. - bool pin_unexpanded_results = 2; - } - - // The specification for personalization. - message PersonalizationSpec { - // The personalization mode of each search request. - enum Mode { - // Default value. Defaults to - // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Let CRS decide whether to use personalization. - AUTO = 1; - - // Disable personalization. - DISABLED = 2; - } - - // Defaults to - // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. - Mode mode = 1; - } - - // The specification for query spell correction. - message SpellCorrectionSpec { - // Enum describing under which mode spell correction should occur. - enum Mode { - // Unspecified spell correction mode. This defaults to - // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Google Retail Search will try to find a spell suggestion if there - // is any and put in the - // [SearchResponse.corrected_query][google.cloud.retail.v2.SearchResponse.corrected_query]. - // The spell suggestion will not be used as the search query. - SUGGESTION_ONLY = 1; - - // Automatic spell correction built by Google Retail Search. Search will - // be based on the corrected query if found. - AUTO = 2; - } - - // The mode under which spell correction should take effect to - // replace the original search query. Default to - // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. - Mode mode = 1; - } - - // The search mode of each search request. - enum SearchMode { - // Default value. In this case both product search and faceted search will - // be performed. Both [SearchResponse.SearchResult] and - // [SearchResponse.Facet] will be returned. - SEARCH_MODE_UNSPECIFIED = 0; - - // Only product search will be performed. The faceted search will be - // disabled. - // - // Only [SearchResponse.SearchResult] will be returned. - // [SearchResponse.Facet] will not be returned, even if - // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] - // or - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] - // is set. - PRODUCT_SEARCH_ONLY = 1; - - // Only faceted search will be performed. The product search will be - // disabled. - // - // When in this mode, one or both of - // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] - // and - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] - // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only - // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] - // will not be returned. - FACETED_SEARCH_ONLY = 2; - } - - // Required. The resource name of the search engine placement, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. - // This field is used to identify the serving configuration name and the set - // of models that will be used to make the search. - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. - // - // Use "default_branch" as the branch ID or leave this field empty, to search - // products under the default branch. - string branch = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Raw search query. - // - // If this field is empty, the request is considered a category browsing - // request and returned results are based on - // [filter][google.cloud.retail.v2.SearchRequest.filter] and - // [page_categories][google.cloud.retail.v2.SearchRequest.page_categories]. - string query = 3; - - // Required. A unique identifier for tracking visitors. For example, this - // could be implemented with an HTTP cookie, which should be able to uniquely - // identify a visitor on a single device. This unique identifier should not - // change if the visitor logs in or out of the website. - // - // This should be the same identifier as - // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id]. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; - - // User information. - UserInfo user_info = 5; - - // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If - // unspecified, defaults to a reasonable value. The maximum allowed value is - // 120. Values above 120 will be coerced to 120. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 7; - - // A page token - // [SearchResponse.next_page_token][google.cloud.retail.v2.SearchResponse.next_page_token], - // received from a previous - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] must - // match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - // error is returned. - string page_token = 8; - - // A 0-indexed integer that specifies the current offset (that is, starting - // result location, amongst the [Product][google.cloud.retail.v2.Product]s - // deemed by the API as relevant) in search results. This field is only - // considered if [page_token][google.cloud.retail.v2.SearchRequest.page_token] - // is unset. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 offset = 9; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. Filter - // expression is case-sensitive. See more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string filter = 10; - - // The default filter that is applied when a user performs a search without - // checking any filters on the search page. - // - // The filter applied to every search request when quality improvement such as - // query expansion is needed. For example, if a query does not have enough - // results, an expanded query with - // [SearchRequest.canonical_filter][google.cloud.retail.v2.SearchRequest.canonical_filter] - // will be returned as a supplement of the original query. This field is - // strongly recommended to achieve high search quality. - // - // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for - // more details about filter syntax. - string canonical_filter = 28; - - // The order in which products are returned. Products can be ordered by - // a field in an [Product][google.cloud.retail.v2.Product] object. Leave it - // unset if ordered by relevance. OrderBy expression is case-sensitive. See - // more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#order). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string order_by = 11; - - // Facet specifications for faceted search. If empty, no facets are returned. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated FacetSpec facet_specs = 12; - - // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - // to enable dynamic facets. Do not set this field. - // - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; - - // Boost specification to boost certain products. See more details at this - // [user guide](https://cloud.google.com/retail/docs/boosting). - // - // Notice that if both [ServingConfig.boost_control_ids][] and - // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] - // are set, the boost conditions from both places are evaluated. If a search - // request matches multiple boost conditions, the final boost score is equal - // to the sum of the boost scores from all matched boost conditions. - BoostSpec boost_spec = 13; - - // The query expansion specification that specifies the conditions under which - // query expansion will occur. See more details at this [user - // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - QueryExpansionSpec query_expansion_spec = 14; - - // The keys to fetch and rollup the matching - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s attributes, - // [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo] or - // [LocalInventory][google.cloud.retail.v2.LocalInventory]s attributes. The - // attributes from all the matching - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s or - // [LocalInventory][google.cloud.retail.v2.LocalInventory]s are merged and - // de-duplicated. Notice that rollup attributes will lead to extra query - // latency. Maximum number of keys is 30. - // - // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], a - // fulfillment type and a fulfillment ID must be provided in the format of - // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - // "pickupInStore" is fulfillment type and "store123" is the store ID. - // - // Supported keys are: - // - // * colorFamilies - // * price - // * originalPrice - // * discount - // * variantId - // * inventory(place_id,price) - // * inventory(place_id,original_price) - // * inventory(place_id,attributes.key), where key is any key in the - // [Product.local_inventories.attributes][google.cloud.retail.v2.LocalInventory.attributes] - // map. - // * attributes.key, where key is any key in the - // [Product.attributes][google.cloud.retail.v2.Product.attributes] map. - // * pickupInStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "pickup-in-store". - // * shipToStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "ship-to-store". - // * sameDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "same-day-delivery". - // * nextDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "next-day-delivery". - // * customFulfillment1.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-1". - // * customFulfillment2.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-2". - // * customFulfillment3.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-3". - // * customFulfillment4.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-4". - // * customFulfillment5.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] - // "custom-type-5". - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - repeated string variant_rollup_keys = 17; - - // The categories associated with a category page. Required for category - // navigation queries to achieve good search quality. The format should be - // the same as - // [UserEvent.page_categories][google.cloud.retail.v2.UserEvent.page_categories]; - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - repeated string page_categories = 23; - - // The search mode of the search request. If not specified, a single search - // request triggers both product search and faceted search. - SearchMode search_mode = 31; - - // The specification for personalization. - PersonalizationSpec personalization_spec = 32; - - // The labels applied to a resource must meet the following requirements: - // - // * Each resource can have multiple labels, up to a maximum of 64. - // * Each label must be a key-value pair. - // * Keys have a minimum length of 1 character and a maximum length of 63 - // characters and cannot be empty. Values can be empty and have a maximum - // length of 63 characters. - // * Keys and values can contain only lowercase letters, numeric characters, - // underscores, and dashes. All characters must use UTF-8 encoding, and - // international characters are allowed. - // * The key portion of a label must be unique. However, you can use the same - // key with multiple resources. - // * Keys must start with a lowercase letter or international character. - // - // See [Google Cloud - // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - // for more details. - map labels = 34; - - // The spell correction specification that specifies the mode under - // which spell correction will take effect. - optional SpellCorrectionSpec spell_correction_spec = 35; -} - -// Response message for -// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. -message SearchResponse { - // Represents the search results. - message SearchResult { - // [Product.id][google.cloud.retail.v2.Product.id] of the searched - // [Product][google.cloud.retail.v2.Product]. - string id = 1; - - // The product data snippet in the search response. Only - // [Product.name][google.cloud.retail.v2.Product.name] is guaranteed to be - // populated. - // - // [Product.variants][google.cloud.retail.v2.Product.variants] contains the - // product variants that match the search query. If there are multiple - // product variants matching the query, top 5 most relevant product variants - // are returned and ordered by relevancy. - // - // If relevancy can be deternmined, use - // [matching_variant_fields][google.cloud.retail.v2.SearchResponse.SearchResult.matching_variant_fields] - // to look up matched product variants fields. If relevancy cannot be - // determined, e.g. when searching "shoe" all products in a shoe product can - // be a match, 5 product variants are returned but order is meaningless. - Product product = 2; - - // The count of matched - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s. - int32 matching_variant_count = 3; - - // If a [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] matches the search query, this - // map indicates which [Product][google.cloud.retail.v2.Product] fields are - // matched. The key is the - // [Product.name][google.cloud.retail.v2.Product.name], the value is a field - // mask of the matched [Product][google.cloud.retail.v2.Product] fields. If - // matched attributes cannot be determined, this map will be empty. - // - // For example, a key "sku1" with field mask - // "products.color_info" indicates there is a match between - // "sku1" [ColorInfo][google.cloud.retail.v2.ColorInfo] and the query. - map matching_variant_fields = 4; - - // The rollup matching - // [variant][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product] attributes. The key is one of - // the - // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2.SearchRequest.variant_rollup_keys]. - // The values are the merged and de-duplicated - // [Product][google.cloud.retail.v2.Product] attributes. Notice that the - // rollup values are respect filter. For example, when filtering by - // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is - // returned. - // - // For textual and numerical attributes, the rollup values is a list of - // string or double values with type - // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if - // there are two variants with colors "red" and "blue", the rollup values - // are - // - // { key: "colorFamilies" - // value { - // list_value { - // values { string_value: "red" } - // values { string_value: "blue" } - // } - // } - // } - // - // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], the rollup - // values is a double value with type - // [google.protobuf.Value][google.protobuf.Value]. For example, - // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there - // are 10 variants in this product are available in the store "store1". - map variant_rollup_values = 5; - } - - // A facet result. - message Facet { - // A facet value which contains value names and their count. - message FacetValue { - // A facet value which contains values. - oneof facet_value { - // Text value of a facet, such as "Black" for facet "colorFamilies". - string value = 1; - - // Interval value for a facet, such as [10, 20) for facet "price". - Interval interval = 2; - } - - // Number of items that have this facet value. - int64 count = 3; - } - - // The key for this facet. E.g., "colorFamilies" or "price" or - // "attributes.attr1". - string key = 1; - - // The facet values for this field. - repeated FacetValue values = 2; - - // Whether the facet is dynamically generated. - bool dynamic_facet = 3; - } - - // Information describing query expansion including whether expansion has - // occurred. - message QueryExpansionInfo { - // Bool describing whether query expansion has occurred. - bool expanded_query = 1; - - // Number of pinned results. This field will only be set when expansion - // happens and - // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] - // is set to true. - int64 pinned_result_count = 2; - } - - // A list of matched items. The order represents the ranking. - repeated SearchResult results = 1; - - // Results of facets requested by user. - repeated Facet facets = 2; - - // The estimated total count of matched items irrespective of pagination. The - // count of [results][google.cloud.retail.v2.SearchResponse.results] returned - // by pagination may be less than the - // [total_size][google.cloud.retail.v2.SearchResponse.total_size] that - // matches. - int32 total_size = 3; - - // Contains the spell corrected query, if found. If the spell correction type - // is AUTOMATIC, then the search results are based on corrected_query. - // Otherwise the original query will be used for search. - string corrected_query = 4; - - // A unique search token. This should be included in the - // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this - // search, which enables accurate attribution of search model performance. - string attribution_token = 5; - - // A token that can be sent as - // [SearchRequest.page_token][google.cloud.retail.v2.SearchRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 6; - - // Query expansion information for the returned results. - QueryExpansionInfo query_expansion_info = 7; - - // The URI of a customer-defined redirect page. If redirect action is - // triggered, no search is performed, and only - // [redirect_uri][google.cloud.retail.v2.SearchResponse.redirect_uri] and - // [attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] - // are set in the response. - string redirect_uri = 10; - - // The fully qualified resource name of applied - // [controls](https://cloud.google.com/retail/docs/serving-control-rules). - repeated string applied_controls = 12; - - // The invalid - // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] - // that are not applied during serving. - repeated SearchRequest.BoostSpec.ConditionBoostSpec - invalid_condition_boost_specs = 14; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto deleted file mode 100644 index fc315f88..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event.proto +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2/common.proto"; -import "google/cloud/retail/v2/product.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// UserEvent captures all metadata information Retail API needs to know about -// how end users interact with customers' website. -message UserEvent { - // Required. User event type. Allowed values are: - // - // * `add-to-cart`: Products being added to cart. - // * `category-page-view`: Special pages such as sale or promotion pages - // viewed. - // * `detail-page-view`: Products detail page viewed. - // * `home-page-view`: Homepage viewed. - // * `promotion-offered`: Promotion is offered to a user. - // * `promotion-not-offered`: Promotion is not offered to a user. - // * `purchase-complete`: User finishing a purchase. - // * `search`: Product search. - // * `shopping-cart-page-view`: User viewing a shopping cart. - string event_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A unique identifier for tracking visitors. - // - // For example, this could be implemented with an HTTP cookie, which should be - // able to uniquely identify a visitor on a single device. This unique - // identifier should not change if the visitor log in/out of the website. - // - // Don't set the field to the same fixed ID for different users. This mixes - // the event history of those users together, which results in degraded model - // quality. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // The field should not contain PII or user-data. We recommend to use Google - // Analytics [Client - // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) - // for this field. - string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // A unique identifier for tracking a visitor session with a length limit of - // 128 bytes. A session is an aggregation of an end user behavior in a time - // span. - // - // A general guideline to populate the sesion_id: - // 1. If user has no activity for 30 min, a new session_id should be assigned. - // 2. The session_id should be unique across users, suggest use uuid or add - // visitor_id as prefix. - string session_id = 21; - - // Only required for - // [UserEventService.ImportUserEvents][google.cloud.retail.v2.UserEventService.ImportUserEvents] - // method. Timestamp of when the user event happened. - google.protobuf.Timestamp event_time = 3; - - // A list of identifiers for the independent experiment groups this user event - // belongs to. This is used to distinguish between user events associated with - // different experiment setups (e.g. using Retail API, using different - // recommendation models). - repeated string experiment_ids = 4; - - // Highly recommended for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. - // This field enables accurate attribution of recommendation model - // performance. - // - // The value must be a valid - // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] - // for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. - // The value must be a valid - // [SearchResponse.attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] - // for user events that are the result of - // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. - // - // This token enables us to accurately attribute page view or purchase back to - // the event and the particular predict response containing this - // clicked/purchased product. If user clicks on product K in the - // recommendation results, pass - // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] - // as a URL parameter to product K's page. When recording events on product - // K's page, log the - // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] - // to this field. - string attribution_token = 5; - - // The main product details related to the event. - // - // This field is optional except for the following event types: - // - // * `add-to-cart` - // * `detail-page-view` - // * `purchase-complete` - // - // In a `search` event, this field represents the products returned to the end - // user on the current page (the end user may have not finished browsing the - // whole page yet). When a new page is returned to the end user, after - // pagination/filtering/ordering even for the same query, a new `search` event - // with different - // [product_details][google.cloud.retail.v2.UserEvent.product_details] is - // desired. The end user may have not finished browsing the whole page yet. - repeated ProductDetail product_details = 6; - - // The main auto-completion details related to the event. - // - // This field should be set for `search` event when autocomplete function is - // enabled and the user clicks a suggestion for search. - CompletionDetail completion_detail = 22; - - // Extra user event features to include in the recommendation model. - // - // If you provide custom attributes for ingested user events, also include - // them in the user events that you associate with prediction requests. Custom - // attribute formatting must be consistent between imported events and events - // provided with prediction requests. This lets the Retail API use - // those custom attributes when training models and serving predictions, which - // helps improve recommendation quality. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * The key must be a UTF-8 encoded string with a length limit of 5,000 - // characters. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 256 characters. - // * For number attributes, at most 400 values are allowed. - // - // For product recommendations, an example of extra user information is - // traffic_channel, which is how a user arrives at the site. Users can arrive - // at the site by coming to the site directly, coming through Google - // search, or in other ways. - map attributes = 7; - - // The ID or name of the associated shopping cart. This ID is used - // to associate multiple items added or present in the cart before purchase. - // - // This can only be set for `add-to-cart`, `purchase-complete`, or - // `shopping-cart-page-view` events. - string cart_id = 8; - - // A transaction represents the entire purchase transaction. - // - // Required for `purchase-complete` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - PurchaseTransaction purchase_transaction = 9; - - // The user's search query. - // - // See [SearchRequest.query][google.cloud.retail.v2.SearchRequest.query] for - // definition. - // - // The value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // At least one of - // [search_query][google.cloud.retail.v2.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - string search_query = 10; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. - // - // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for - // definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string filter = 16; - - // The order in which products are returned. - // - // See [SearchRequest.order_by][google.cloud.retail.v2.SearchRequest.order_by] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string order_by = 17; - - // An integer that specifies the current offset for pagination (the 0-indexed - // starting location, amongst the products deemed by the API as relevant). - // - // See [SearchRequest.offset][google.cloud.retail.v2.SearchRequest.offset] for - // definition. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - int32 offset = 18; - - // The categories associated with a category page. - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - // - // Required for `category-page-view` events. At least one of - // [search_query][google.cloud.retail.v2.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated string page_categories = 11; - - // User information. - UserInfo user_info = 12; - - // Complete URL (window.location.href) of the user's current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. Maximum length 5,000 - // characters. - string uri = 13; - - // The referrer URL of the current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string referrer_uri = 14; - - // A unique ID of a web page view. - // - // This should be kept the same for all user events triggered from the same - // pageview. For example, an item detail page view could trigger multiple - // events as the user is browsing the page. The `pageViewId` property should - // be kept the same for all these events so that they can be grouped together - // properly. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string page_view_id = 15; -} - -// Detailed product information associated with a user event. -message ProductDetail { - // Required. [Product][google.cloud.retail.v2.Product] information. - // - // Required field(s): - // - // * [Product.id][google.cloud.retail.v2.Product.id] - // - // Optional override field(s): - // - // * [Product.price_info][google.cloud.retail.v2.Product.price_info] - // - // If any supported optional fields are provided, we will treat them as a full - // override when looking up product information from the catalog. Thus, it is - // important to ensure that the overriding fields are accurate and - // complete. - // - // All other product fields are ignored and instead populated via catalog - // lookup after event ingestion. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Quantity of the product associated with the user event. - // - // For example, this field will be 2 if two products are added to the shopping - // cart for `purchase-complete` event. Required for `add-to-cart` and - // `purchase-complete` event types. - google.protobuf.Int32Value quantity = 2; -} - -// Detailed completion information including completion attribution token and -// clicked completion info. -message CompletionDetail { - // Completion attribution token in - // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2.CompleteQueryResponse.attribution_token]. - string completion_attribution_token = 1; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion]. - string selected_suggestion = 2; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion] - // position, starting from 0. - int32 selected_position = 3; -} - -// A transaction represents the entire purchase transaction. -message PurchaseTransaction { - // The transaction ID with a length limit of 128 characters. - string id = 1; - - // Required. Total non-zero revenue or grand total associated with the - // transaction. This value include shipping, tax, or other adjustments to - // total revenue that you want to include as part of your revenue - // calculations. - float revenue = 2 [(google.api.field_behavior) = REQUIRED]; - - // All the taxes associated with the transaction. - float tax = 3; - - // All the costs associated with the products. These can be manufacturing - // costs, shipping expenses not borne by the end user, or any other costs, - // such that: - // - // * Profit = [revenue][google.cloud.retail.v2.PurchaseTransaction.revenue] - - // [tax][google.cloud.retail.v2.PurchaseTransaction.tax] - - // [cost][google.cloud.retail.v2.PurchaseTransaction.cost] - float cost = 4; - - // Required. Currency code. Use three-character ISO-4217 code. - string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto b/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto deleted file mode 100644 index 4446906a..00000000 --- a/owl-bot-staging/v2/protos/google/cloud/retail/v2/user_event_service.proto +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/httpbody.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/import_config.proto"; -import "google/cloud/retail/v2/purge_config.proto"; -import "google/cloud/retail/v2/user_event.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventServiceProto"; -option java_package = "com.google.cloud.retail.v2"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2"; -option ruby_package = "Google::Cloud::Retail::V2"; - -// Service for ingesting end user actions on the customer website. -service UserEventService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Writes a single user event. - rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" - body: "user_event" - }; - } - - // Writes a single user event from the browser. This uses a GET request to - // due to browser restriction of POST-ing to a 3rd party domain. - // - // This method is used only by the Retail API JavaScript pixel and Google Tag - // Manager. Users should not call this method directly. - rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" - }; - } - - // Deletes permanently all user events specified by the filter provided. - // Depending on the number of events specified by the filter, this operation - // could take hours or days to complete. To test a filter, use the list - // command first. - rpc PurgeUserEvents(PurgeUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.PurgeUserEventsResponse" - metadata_type: "google.cloud.retail.v2.PurgeMetadata" - }; - } - - // Bulk import of User events. Request processing might be - // synchronous. Events that already exist are skipped. - // Use this method for backfilling historical user events. - // - // Operation.response is of type ImportResponse. Note that it is - // possible for a subset of the items to be successfully inserted. - // Operation.metadata is of type ImportMetadata. - rpc ImportUserEvents(ImportUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.ImportUserEventsResponse" - metadata_type: "google.cloud.retail.v2.ImportMetadata" - }; - } - - // Starts a user event rejoin operation with latest product catalog. Events - // will not be annotated with detailed product information if product is - // missing from the catalog at the time the user event is ingested, and these - // events are stored as unjoined events with a limited usage on training and - // serving. This method can be used to start a join operation on specified - // events with latest version of product catalog. It can also be used to - // correct events joined with the wrong product catalog. A rejoin operation - // can take hours or days to complete. - rpc RejoinUserEvents(RejoinUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "RejoinUserEventsResponse" - metadata_type: "RejoinUserEventsMetadata" - }; - } -} - -// Request message for WriteUserEvent method. -message WriteUserEventRequest { - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User event to write. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // Required. The parent catalog name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. URL encoded UserEvent proto with a length limit of 2,000,000 - // characters. - string user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // The URL including cgi-parameters but excluding the hash fragment with a - // length limit of 5,000 characters. This is often more useful than the - // referer URL, because many browsers only send the domain for 3rd party - // requests. - string uri = 3; - - // The event timestamp in milliseconds. This prevents browser caching of - // otherwise identical get requests. The name is abbreviated to reduce the - // payload bytes. - int64 ets = 4; -} - -// Request message for RejoinUserEvents method. -message RejoinUserEventsRequest { - // The scope of user events to be rejoined with the latest product catalog. - // If the rejoining aims at reducing number of unjoined events, set - // UserEventRejoinScope to UNJOINED_EVENTS. - // If the rejoining aims at correcting product catalog information in joined - // events, set UserEventRejoinScope to JOINED_EVENTS. - // If all events needs to be rejoined, set UserEventRejoinScope to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. - enum UserEventRejoinScope { - // Rejoin all events with the latest product catalog, including both joined - // events and unjoined events. - USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; - - // Only rejoin joined events with the latest product catalog. - JOINED_EVENTS = 1; - - // Only rejoin unjoined events with the latest product catalog. - UNJOINED_EVENTS = 2; - } - - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The type of the user event rejoin to define the scope and range of the user - // events to be rejoined with the latest product catalog. Defaults to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - // invalid integer value. - UserEventRejoinScope user_event_rejoin_scope = 2; -} - -// Response message for RejoinUserEvents method. -message RejoinUserEventsResponse { - // Number of user events that were joined with latest product catalog. - int64 rejoined_user_events_count = 1; -} - -// Metadata for RejoinUserEvents method. -message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js deleted file mode 100644 index fa840318..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/catalog_service.get_default_branch.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2_generated_CatalogService_GetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.getDefaultBranch(request); - console.log(response); - } - - callGetDefaultBranch(); - // [END retail_v2_generated_CatalogService_GetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js deleted file mode 100644 index b5c79c51..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/catalog_service.list_catalogs.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2_generated_CatalogService_ListCatalogs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The account resource name with an associated location. - * If the caller does not have permission to list - * Catalog google.cloud.retail.v2.Catalog s under this location, regardless - * of whether or not this location exists, a PERMISSION_DENIED error is - * returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Catalog google.cloud.retail.v2.Catalog s to return. If - * unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListCatalogsResponse.next_page_token google.cloud.retail.v2.ListCatalogsResponse.next_page_token, - * received from a previous - * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callListCatalogs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listCatalogsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCatalogs(); - // [END retail_v2_generated_CatalogService_ListCatalogs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js deleted file mode 100644 index f03f4c36..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/catalog_service.set_default_branch.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2_generated_CatalogService_SetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * The final component of the resource name of a branch. - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * If there are no sufficient active products in the targeted branch and - * force google.cloud.retail.v2.SetDefaultBranchRequest.force is not set, a - * FAILED_PRECONDITION error is returned. - */ - // const branchId = 'abc123' - /** - * Some note on this request, this can be retrieved by - * CatalogService.GetDefaultBranch google.cloud.retail.v2.CatalogService.GetDefaultBranch - * before next valid default branch set occurs. - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const note = 'abc123' - /** - * If set to true, it permits switching to a branch with - * branch_id google.cloud.retail.v2.SetDefaultBranchRequest.branch_id even - * if it has no sufficient active products. - */ - // const force = true - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callSetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.setDefaultBranch(request); - console.log(response); - } - - callSetDefaultBranch(); - // [END retail_v2_generated_CatalogService_SetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js b/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.js deleted file mode 100644 index 33d552b5..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/catalog_service.update_catalog.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(catalog) { - // [START retail_v2_generated_CatalogService_UpdateCatalog_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Catalog google.cloud.retail.v2.Catalog to update. - * If the caller does not have permission to update the - * Catalog google.cloud.retail.v2.Catalog, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * If the Catalog google.cloud.retail.v2.Catalog to update does not exist, - * a NOT_FOUND error is returned. - */ - // const catalog = {} - /** - * Indicates which fields in the provided - * Catalog google.cloud.retail.v2.Catalog to update. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCatalog() { - // Construct request - const request = { - catalog, - }; - - // Run request - const response = await retailClient.updateCatalog(request); - console.log(response); - } - - callUpdateCatalog(); - // [END retail_v2_generated_CatalogService_UpdateCatalog_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js b/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js deleted file mode 100644 index 51c1efcd..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/completion_service.complete_query.js +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(catalog, query) { - // [START retail_v2_generated_CompletionService_CompleteQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Catalog for which the completion is performed. - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * Required. The query used to generate suggestions. - * The maximum number of allowed characters is 255. - */ - // const query = 'abc123' - /** - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see Tags for - * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - */ - // const languageCodes = 'abc123' - /** - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * Supported formats: - * * `UNKNOWN_DEVICE_TYPE` - * * `DESKTOP` - * * `MOBILE` - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - */ - // const deviceType = 'abc123' - /** - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * CompletionService.ImportCompletionData google.cloud.retail.v2.CompletionService.ImportCompletionData. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * Current supported values: - * * user-data - * * cloud-retail: - * This option requires enabling auto-learning function first. See - * guidelines (https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). - */ - // const dataset = 'abc123' - /** - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value CompletionConfig.max_suggestions . - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - */ - // const maxSuggestions = 1234 - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callCompleteQuery() { - // Construct request - const request = { - catalog, - query, - }; - - // Run request - const response = await retailClient.completeQuery(request); - console.log(response); - } - - callCompleteQuery(); - // [END retail_v2_generated_CompletionService_CompleteQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js b/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.js deleted file mode 100644 index 4ccdcfe6..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/completion_service.import_completion_data.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, inputConfig) { - // [START retail_v2_generated_CompletionService_ImportCompletionData_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog which the suggestions dataset belongs to. - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callImportCompletionData() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importCompletionData(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportCompletionData(); - // [END retail_v2_generated_CompletionService_ImportCompletionData_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js b/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js deleted file mode 100644 index d2db6c72..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/prediction_service.predict.js +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, userEvent) { - // [START retail_v2_generated_PredictionService_Predict_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see Managing - * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - */ - // const placement = 'abc123' - /** - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - * Don't set - * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id or - * UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id to the same - * fixed ID for different users. If you are trying to receive non-personalized - * recommendations (not recommended; this can negatively impact model - * performance), instead set - * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id to a - * random unique ID and leave - * UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id unset. - */ - // const userEvent = {} - /** - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - */ - // const pageSize = 1234 - /** - * The previous PredictResponse.next_page_token. - */ - // const pageToken = 'abc123' - /** - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * Examples: - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - */ - // const filter = 'abc123' - /** - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - */ - // const validateOnly = true - /** - * Additional domain specific parameters for the predictions. - * Allowed values: - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - */ - // const params = 1234 - /** - * The labels applied to a resource must meet the following requirements: - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters and cannot be empty. Values can be empty and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * See Google Cloud - * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - */ - // const labels = 1234 - - // Imports the Retail library - const {PredictionServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new PredictionServiceClient(); - - async function callPredict() { - // Construct request - const request = { - placement, - userEvent, - }; - - // Run request - const response = await retailClient.predict(request); - console.log(response); - } - - callPredict(); - // [END retail_v2_generated_PredictionService_Predict_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js b/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js deleted file mode 100644 index 79ea0522..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.add_fulfillment_places.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2_generated_ProductService_AddFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type, such as - * the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type. Duplicate - * IDs will be automatically ignored. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * If the total number of place IDs exceeds 2000 for this - * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type after - * adding, then the update will be rejected. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, the fulfillment information will still be processed and retained for - * at most 1 day and processed once the - * Product google.cloud.retail.v2.Product is created. If set to false, a - * NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddFulfillmentPlaces(); - // [END retail_v2_generated_ProductService_AddFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js b/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js deleted file mode 100644 index f0598e36..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.add_local_inventories.js +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, localInventories) { - // [START retail_v2_generated_ProductService_AddLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - */ - // const localInventories = 1234 - /** - * Indicates which inventory fields in the provided list of - * LocalInventory google.cloud.retail.v2.LocalInventory to update. The - * field is updated to the provided value. - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const addMask = {} - /** - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, the local inventory will still be processed and retained for at most - * 1 day and processed once the Product google.cloud.retail.v2.Product is - * created. If set to false, a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddLocalInventories() { - // Construct request - const request = { - product, - localInventories, - }; - - // Run request - const [operation] = await retailClient.addLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddLocalInventories(); - // [END retail_v2_generated_ProductService_AddLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js deleted file mode 100644 index e64ffbdf..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.create_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, product, productId) { - // [START retail_v2_generated_ProductService_CreateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - */ - // const parent = 'abc123' - /** - * Required. The Product google.cloud.retail.v2.Product to create. - */ - // const product = {} - /** - * Required. The ID to use for the Product google.cloud.retail.v2.Product, - * which will become the final component of the - * Product.name google.cloud.retail.v2.Product.name. - * If the caller does not have permission to create the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * This field must be unique among all - * Product google.cloud.retail.v2.Product s with the same - * parent google.cloud.retail.v2.CreateProductRequest.parent. Otherwise, an - * ALREADY_EXISTS error is returned. - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const productId = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - productId, - }; - - // Run request - const response = await retailClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END retail_v2_generated_ProductService_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.js deleted file mode 100644 index 7838dfa1..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.delete_product.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(name) { - // [START retail_v2_generated_ProductService_DeleteProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to delete the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2.Product to delete does not exist, - * a NOT_FOUND error is returned. - * The Product google.cloud.retail.v2.Product to delete can neither be a - * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION - * Product google.cloud.retail.v2.Product member nor a - * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY - * Product google.cloud.retail.v2.Product with more than one - * variants google.cloud.retail.v2.Product.Type.VARIANT. Otherwise, an - * INVALID_ARGUMENT error is returned. - * All inventory information for the named - * Product google.cloud.retail.v2.Product will be deleted. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END retail_v2_generated_ProductService_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js deleted file mode 100644 index 007c35ea..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.get_product.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2_generated_ProductService_GetProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * If the requested Product google.cloud.retail.v2.Product does not exist, - * a NOT_FOUND error is returned. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END retail_v2_generated_ProductService_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js b/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js deleted file mode 100644 index 3de37997..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.import_products.js +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2_generated_ProductService_ImportProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. - */ - // const errorsConfig = {} - /** - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - */ - // const updateMask = {} - /** - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * ReconciliationMode.INCREMENTAL google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL. - */ - // const reconciliationMode = {} - /** - * Full Pub/Sub topic name for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has - * to be within the same project as - * ImportProductsRequest.parent google.cloud.retail.v2.ImportProductsRequest.parent. - * Make sure that both - * `cloud-retail-customer-data-access@system.gserviceaccount.com` and - * `service-@gcp-sa-retail.iam.gserviceaccount.com` - * have the `pubsub.topics.publish` IAM permission on the topic. - * Only supported when - * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode - * is set to `FULL`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callImportProducts() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProducts(); - // [END retail_v2_generated_ProductService_ImportProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js b/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js deleted file mode 100644 index 00b71a9a..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.list_products.js +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2_generated_ProductService_ListProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * If the caller does not have permission to list - * Product google.cloud.retail.v2.Product s under this branch, regardless of - * whether or not this branch exists, a PERMISSION_DENIED error is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Product google.cloud.retail.v2.Product s to return. If - * unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT error is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListProductsResponse.next_page_token google.cloud.retail.v2.ListProductsResponse.next_page_token, - * received from a previous - * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2.ListProductsRequest.filter is unset. - * * List Product.Type.VARIANT google.cloud.retail.v2.Product.Type.VARIANT - * Product google.cloud.retail.v2.Product s sharing the same - * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY - * Product google.cloud.retail.v2.Product. For example: - * `primary_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2.Product s bundled in a - * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION - * Product google.cloud.retail.v2.Product. - * For example: - * `collection_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2.Product s with a partibular type. - * For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * If the specified - * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY - * Product google.cloud.retail.v2.Product or - * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION - * Product google.cloud.retail.v2.Product does not exist, a NOT_FOUND error - * is returned. - */ - // const filter = 'abc123' - /** - * The fields of Product google.cloud.retail.v2.Product to return in the - * responses. If not set or empty, the following fields are returned: - * * Product.name google.cloud.retail.v2.Product.name - * * Product.id google.cloud.retail.v2.Product.id - * * Product.title google.cloud.retail.v2.Product.title - * * Product.uri google.cloud.retail.v2.Product.uri - * * Product.images google.cloud.retail.v2.Product.images - * * Product.price_info google.cloud.retail.v2.Product.price_info - * * Product.brands google.cloud.retail.v2.Product.brands - * If "*" is provided, all fields are returned. - * Product.name google.cloud.retail.v2.Product.name is always returned no - * matter what mask is set. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const readMask = {} - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END retail_v2_generated_ProductService_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js deleted file mode 100644 index 8824fefa..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_fulfillment_places.js +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to - * Product.fulfillment_info.type google.cloud.retail.v2.FulfillmentInfo.type. - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type, such as - * the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, the fulfillment information will still be processed and retained for - * at most 1 day and processed once the - * Product google.cloud.retail.v2.Product is created. If set to false, a - * NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveFulfillmentPlaces(); - // [END retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js b/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js deleted file mode 100644 index 6332ed05..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.remove_local_inventories.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, placeIds) { - // [START retail_v2_generated_ProductService_RemoveLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of Product google.cloud.retail.v2.Product, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - */ - // const placeIds = 'abc123' - /** - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * Product google.cloud.retail.v2.Product is created. If set to false, a - * NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveLocalInventories() { - // Construct request - const request = { - product, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveLocalInventories(); - // [END retail_v2_generated_ProductService_RemoveLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js b/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js deleted file mode 100644 index 4f35c54e..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.set_inventory.js +++ /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 -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(inventory) { - // [START retail_v2_generated_ProductService_SetInventory_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The inventory information to update. The allowable fields to - * update are: - * * Product.price_info google.cloud.retail.v2.Product.price_info - * * Product.availability google.cloud.retail.v2.Product.availability - * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info - * The updated inventory fields must be specified in - * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask. - * If SetInventoryRequest.inventory.name is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2.Product named in - * Product.name google.cloud.retail.v2.Product.name, regardless of whether - * or not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2.Product to update does not have - * existing inventory information, the provided inventory information will be - * inserted. - * If the Product google.cloud.retail.v2.Product to update has existing - * inventory information, the provided inventory information will be merged - * while respecting the last update time for each inventory field, using the - * provided or default value for - * SetInventoryRequest.set_time google.cloud.retail.v2.SetInventoryRequest.set_time. - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in SetInventoryRequest.inventory.fulfillment_info - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types to clear in - * SetInventoryRequest.inventory.fulfillment_info - * * Checks that only the desired fulfillment info types have empty - * SetInventoryRequest.inventory.fulfillment_info.place_ids - * The last update time is recorded for the following inventory fields: - * * Product.price_info google.cloud.retail.v2.Product.price_info - * * Product.availability google.cloud.retail.v2.Product.availability - * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info - * If a full overwrite of inventory information while ignoring timestamps is - * needed, UpdateProduct should be invoked instead. - */ - // const inventory = {} - /** - * Indicates which inventory fields in the provided - * Product google.cloud.retail.v2.Product to update. - * At least one field must be provided. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const setMask = {} - /** - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - */ - // const setTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product with name - * Product.name google.cloud.retail.v2.Product.name is not found, the - * inventory update will still be processed and retained for at most 1 day - * until the Product google.cloud.retail.v2.Product is created. If set to - * false, a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callSetInventory() { - // Construct request - const request = { - inventory, - }; - - // Run request - const [operation] = await retailClient.setInventory(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInventory(); - // [END retail_v2_generated_ProductService_SetInventory_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js b/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js deleted file mode 100644 index 7c7a9f41..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/product_service.update_product.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START retail_v2_generated_ProductService_UpdateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The product to update/create. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2.Product, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2.Product to update does not exist - * and - * allow_missing google.cloud.retail.v2.UpdateProductRequest.allow_missing - * is not set, a NOT_FOUND error is returned. - */ - // const product = {} - /** - * Indicates which fields in the provided - * Product google.cloud.retail.v2.Product to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * The attribute key can be updated by setting the mask path as - * "attributes.${key_name}". If a key name is present in the mask but not in - * the patching product from the request, this key will be deleted after the - * update. - */ - // const updateMask = {} - /** - * If set to true, and the Product google.cloud.retail.v2.Product is not - * found, a new Product google.cloud.retail.v2.Product will be created. In - * this situation, `update_mask` is ignored. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await retailClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END retail_v2_generated_ProductService_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/search_service.search.js b/owl-bot-staging/v2/samples/generated/v2/search_service.search.js deleted file mode 100644 index 26118e14..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/search_service.search.js +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, visitorId) { - // [START retail_v2_generated_SearchService_Search_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - */ - // const placement = 'abc123' - /** - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - */ - // const branch = 'abc123' - /** - * Raw search query. - * If this field is empty, the request is considered a category browsing - * request and returned results are based on - * filter google.cloud.retail.v2.SearchRequest.filter and - * page_categories google.cloud.retail.v2.SearchRequest.page_categories. - */ - // const query = 'abc123' - /** - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * This should be the same identifier as - * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * User information. - */ - // const userInfo = {} - /** - * Maximum number of Product google.cloud.retail.v2.Product s to return. If - * unspecified, defaults to a reasonable value. The maximum allowed value is - * 120. Values above 120 will be coerced to 120. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * SearchResponse.next_page_token google.cloud.retail.v2.SearchResponse.next_page_token, - * received from a previous - * SearchService.Search google.cloud.retail.v2.SearchService.Search call. - * Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SearchService.Search google.cloud.retail.v2.SearchService.Search must - * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - * error is returned. - */ - // const pageToken = 'abc123' - /** - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the Product google.cloud.retail.v2.Product s - * deemed by the API as relevant) in search results. This field is only - * considered if page_token google.cloud.retail.v2.SearchRequest.page_token - * is unset. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const offset = 1234 - /** - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const filter = 'abc123' - /** - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * SearchRequest.canonical_filter google.cloud.retail.v2.SearchRequest.canonical_filter - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * See SearchRequest.filter google.cloud.retail.v2.SearchRequest.filter for - * more details about filter syntax. - */ - // const canonicalFilter = 'abc123' - /** - * The order in which products are returned. Products can be ordered by - * a field in an Product google.cloud.retail.v2.Product object. Leave it - * unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#order). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const orderBy = 'abc123' - /** - * Facet specifications for faceted search. If empty, no facets are returned. - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - */ - // const facetSpecs = 1234 - /** - * Boost specification to boost certain products. See more details at this - * user guide (https://cloud.google.com/retail/docs/boosting). - * Notice that if both ServingConfig.boost_control_ids and - * SearchRequest.boost_spec google.cloud.retail.v2.SearchRequest.boost_spec - * are set, the boost conditions from both places are evaluated. If a search - * request matches multiple boost conditions, the final boost score is equal - * to the sum of the boost scores from all matched boost conditions. - */ - // const boostSpec = {} - /** - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this user - * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). - */ - // const queryExpansionSpec = {} - /** - * The keys to fetch and rollup the matching - * variant google.cloud.retail.v2.Product.Type.VARIANT - * Product google.cloud.retail.v2.Product s attributes, - * FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo or - * LocalInventory google.cloud.retail.v2.LocalInventory s attributes. The - * attributes from all the matching - * variant google.cloud.retail.v2.Product.Type.VARIANT - * Product google.cloud.retail.v2.Product s or - * LocalInventory google.cloud.retail.v2.LocalInventory s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * For FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * Supported keys are: - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * Product.local_inventories.attributes google.cloud.retail.v2.LocalInventory.attributes - * map. - * * attributes.key, where key is any key in the - * Product.attributes google.cloud.retail.v2.Product.attributes map. - * * pickupInStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "pickup-in-store". - * * shipToStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-1". - * * customFulfillment2.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-2". - * * customFulfillment3.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-3". - * * customFulfillment4.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-4". - * * customFulfillment5.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type - * "custom-type-5". - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - */ - // const variantRollupKeys = 'abc123' - /** - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * UserEvent.page_categories google.cloud.retail.v2.UserEvent.page_categories; - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : "Sales > 2017 Black Friday Deals". - */ - // const pageCategories = 'abc123' - /** - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - */ - // const searchMode = {} - /** - * The specification for personalization. - */ - // const personalizationSpec = {} - /** - * The labels applied to a resource must meet the following requirements: - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters and cannot be empty. Values can be empty and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * See Google Cloud - * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - */ - // const labels = 1234 - /** - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - */ - // const spellCorrectionSpec = {} - - // Imports the Retail library - const {SearchServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new SearchServiceClient(); - - async function callSearch() { - // Construct request - const request = { - placement, - visitorId, - }; - - // Run request - const iterable = await retailClient.searchAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearch(); - // [END retail_v2_generated_SearchService_Search_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json deleted file mode 100644 index 13e48207..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json +++ /dev/null @@ -1,1303 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-retail", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.retail.v2", - "version": "v2" - } - ] - }, - "snippets": [ - { - "regionTag": "retail_v2_generated_CatalogService_ListCatalogs_async", - "title": "CatalogService listCatalogs Sample", - "origin": "API_DEFINITION", - "description": " Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with the project.", - "canonical": true, - "file": "catalog_service.list_catalogs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.ListCatalogsResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_UpdateCatalog_async", - "title": "CatalogService updateCatalog Sample", - "origin": "API_DEFINITION", - "description": " Updates the [Catalog][google.cloud.retail.v2.Catalog]s.", - "canonical": true, - "file": "catalog_service.update_catalog.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": ".google.cloud.retail.v2.Catalog" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.Catalog", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_SetDefaultBranch_async", - "title": "CatalogService setDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", - "canonical": true, - "file": "catalog_service.set_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "branch_id", - "type": "TYPE_STRING" - }, - { - "name": "note", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_GetDefaultBranch_async", - "title": "CatalogService getDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] method under a specified parent catalog.", - "canonical": true, - "file": "catalog_service.get_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.GetDefaultBranchResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CompletionService_CompleteQuery_async", - "title": "CatalogService completeQuery Sample", - "origin": "API_DEFINITION", - "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 108, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "language_codes", - "type": "TYPE_STRING[]" - }, - { - "name": "device_type", - "type": "TYPE_STRING" - }, - { - "name": "dataset", - "type": "TYPE_STRING" - }, - { - "name": "max_suggestions", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.retail.v2.CompleteQueryResponse", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2.CompletionServiceClient" - }, - "method": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CompletionService_ImportCompletionData_async", - "title": "CatalogService importCompletionData Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.import_completion_data.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2.CompletionDataInputConfig" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2.CompletionServiceClient" - }, - "method": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_PredictionService_Predict_async", - "title": "CatalogService predict Sample", - "origin": "API_DEFINITION", - "description": " Makes a recommendation prediction.", - "canonical": true, - "file": "prediction_service.predict.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 162, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2.PredictionService.Predict", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2.UserEvent" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "params", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.retail.v2.PredictResponse", - "client": { - "shortName": "PredictionServiceClient", - "fullName": "google.cloud.retail.v2.PredictionServiceClient" - }, - "method": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2.PredictionService.Predict", - "service": { - "shortName": "PredictionService", - "fullName": "google.cloud.retail.v2.PredictionService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_CreateProduct_async", - "title": "CatalogService createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Product][google.cloud.retail.v2.Product].", - "canonical": true, - "file": "product_service.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.retail.v2.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_GetProduct_async", - "title": "CatalogService getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Product][google.cloud.retail.v2.Product].", - "canonical": true, - "file": "product_service.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2.ProductService.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2.ProductService.GetProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_ListProducts_async", - "title": "CatalogService listProducts Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Product][google.cloud.retail.v2.Product]s.", - "canonical": true, - "file": "product_service.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 122, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2.ProductService.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "read_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.ListProductsResponse", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2.ProductService.ListProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_UpdateProduct_async", - "title": "CatalogService updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Product][google.cloud.retail.v2.Product].", - "canonical": true, - "file": "product_service.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 76, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.retail.v2.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.retail.v2.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_DeleteProduct_async", - "title": "CatalogService deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Product][google.cloud.retail.v2.Product].", - "canonical": true, - "file": "product_service.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_ImportProducts_async", - "title": "CatalogService importProducts Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. Request processing may be synchronous. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2.Product]s to be successfully updated.", - "canonical": true, - "file": "product_service.import_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 91, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2.ProductInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2.ImportErrorsConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "reconciliation_mode", - "type": ".google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_SetInventory_async", - "title": "CatalogService setInventory Sample", - "origin": "API_DEFINITION", - "description": " Updates inventory information for a [Product][google.cloud.retail.v2.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.set_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 116, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2.ProductService.SetInventory", - "async": true, - "parameters": [ - { - "name": "inventory", - "type": ".google.cloud.retail.v2.Product" - }, - { - "name": "set_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "set_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2.ProductService.SetInventory", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_AddFulfillmentPlaces_async", - "title": "CatalogService addFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 107, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async", - "title": "CatalogService removeFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 104, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_AddLocalInventories_async", - "title": "CatalogService addLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Updates local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 91, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "local_inventories", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "add_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ProductService_RemoveLocalInventories_async", - "title": "CatalogService removeLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Remove local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2.ProductServiceClient" - }, - "method": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_SearchService_Search_async", - "title": "CatalogService search Sample", - "origin": "API_DEFINITION", - "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 280, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2.SearchService.Search", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "branch", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "user_info", - "type": ".google.cloud.retail.v2.UserInfo" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "offset", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "canonical_filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "facet_specs", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "dynamic_facet_spec", - "type": ".google.cloud.retail.v2.SearchRequest.DynamicFacetSpec" - }, - { - "name": "boost_spec", - "type": ".google.cloud.retail.v2.SearchRequest.BoostSpec" - }, - { - "name": "query_expansion_spec", - "type": ".google.cloud.retail.v2.SearchRequest.QueryExpansionSpec" - }, - { - "name": "variant_rollup_keys", - "type": "TYPE_STRING[]" - }, - { - "name": "page_categories", - "type": "TYPE_STRING[]" - }, - { - "name": "search_mode", - "type": ".google.cloud.retail.v2.SearchRequest.SearchMode" - }, - { - "name": "personalization_spec", - "type": ".google.cloud.retail.v2.SearchRequest.PersonalizationSpec" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "spell_correction_spec", - "type": ".google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec" - } - ], - "resultType": ".google.cloud.retail.v2.SearchResponse", - "client": { - "shortName": "SearchServiceClient", - "fullName": "google.cloud.retail.v2.SearchServiceClient" - }, - "method": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2.SearchService.Search", - "service": { - "shortName": "SearchService", - "fullName": "google.cloud.retail.v2.SearchService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_WriteUserEvent_async", - "title": "CatalogService writeUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event.", - "canonical": true, - "file": "user_event_service.write_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2.UserEvent" - } - ], - "resultType": ".google.cloud.retail.v2.UserEvent", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_CollectUserEvent_async", - "title": "CatalogService collectUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", - "canonical": true, - "file": "user_event_service.collect_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.api.HttpBody", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_PurgeUserEvents_async", - "title": "CatalogService purgeUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", - "canonical": true, - "file": "user_event_service.purge_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 82, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_ImportUserEvents_async", - "title": "CatalogService importUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", - "canonical": true, - "file": "user_event_service.import_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2.UserEventInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2.ImportErrorsConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_UserEventService_RejoinUserEvents_async", - "title": "CatalogService rejoinUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", - "canonical": true, - "file": "user_event_service.rejoin_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event_rejoin_scope", - "type": ".google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2.UserEventServiceClient" - }, - "method": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2.UserEventService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js deleted file mode 100644 index 40992711..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.collect_user_event.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2_generated_UserEventService_CollectUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - */ - // const userEvent = 'abc123' - /** - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - */ - // const uri = 'abc123' - /** - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - */ - // const ets = 1234 - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callCollectUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.collectUserEvent(request); - console.log(response); - } - - callCollectUserEvent(); - // [END retail_v2_generated_UserEventService_CollectUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js deleted file mode 100644 index fa18d38d..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.import_user_events.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2_generated_UserEventService_ImportUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. `projects/1234/locations/global/catalogs/default_catalog` - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - */ - // const errorsConfig = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callImportUserEvents() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportUserEvents(); - // [END retail_v2_generated_UserEventService_ImportUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js deleted file mode 100644 index 0a008d5d..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.purge_user_events.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, filter) { - // [START retail_v2_generated_UserEventService_PurgeUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - */ - // const parent = 'abc123' - /** - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * * `eventType`: Double quoted - * UserEvent.event_type google.cloud.retail.v2.UserEvent.event_type string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * Examples: - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * The filtering fields are assumed to have an implicit AND. - */ - // const filter = 'abc123' - /** - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - */ - // const force = true - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callPurgeUserEvents() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await retailClient.purgeUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeUserEvents(); - // [END retail_v2_generated_UserEventService_PurgeUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js deleted file mode 100644 index 925f96b6..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.rejoin_user_events.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2_generated_UserEventService_RejoinUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - */ - // const userEventRejoinScope = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callRejoinUserEvents() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await retailClient.rejoinUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRejoinUserEvents(); - // [END retail_v2_generated_UserEventService_RejoinUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js b/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js deleted file mode 100644 index 6df073a3..00000000 --- a/owl-bot-staging/v2/samples/generated/v2/user_event_service.write_user_event.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2_generated_UserEventService_WriteUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callWriteUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.writeUserEvent(request); - console.log(response); - } - - callWriteUserEvent(); - // [END retail_v2_generated_UserEventService_WriteUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/src/index.ts b/owl-bot-staging/v2/src/index.ts deleted file mode 100644 index 28988c03..00000000 --- a/owl-bot-staging/v2/src/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 v2 from './v2'; -const CatalogServiceClient = v2.CatalogServiceClient; -type CatalogServiceClient = v2.CatalogServiceClient; -const CompletionServiceClient = v2.CompletionServiceClient; -type CompletionServiceClient = v2.CompletionServiceClient; -const PredictionServiceClient = v2.PredictionServiceClient; -type PredictionServiceClient = v2.PredictionServiceClient; -const ProductServiceClient = v2.ProductServiceClient; -type ProductServiceClient = v2.ProductServiceClient; -const SearchServiceClient = v2.SearchServiceClient; -type SearchServiceClient = v2.SearchServiceClient; -const UserEventServiceClient = v2.UserEventServiceClient; -type UserEventServiceClient = v2.UserEventServiceClient; -export {v2, CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient}; -export default {v2, CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_client.ts b/owl-bot-staging/v2/src/v2/catalog_service_client.ts deleted file mode 100644 index c8d68a6b..00000000 --- a/owl-bot-staging/v2/src/v2/catalog_service_client.ts +++ /dev/null @@ -1,1058 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/catalog_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './catalog_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for managing catalog configuration. - * @class - * @memberof v2 - */ -export class CatalogServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - catalogServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CatalogServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CatalogServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listCatalogs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.CatalogService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.catalogServiceStub) { - return this.catalogServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.CatalogService. - this.catalogServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.CatalogService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.CatalogService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const catalogServiceStubMethods = - ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch']; - for (const methodName of catalogServiceStubMethods) { - const callPromise = this.catalogServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.catalogServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Updates the {@link google.cloud.retail.v2.Catalog|Catalog}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2.Catalog} request.catalog - * Required. The {@link google.cloud.retail.v2.Catalog|Catalog} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2.Catalog|Catalog}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2.Catalog|Catalog} to update does not exist, - * a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2.Catalog|Catalog} to update. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2.Catalog}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/catalog_service.update_catalog.js - * region_tag:retail_v2_generated_CatalogService_UpdateCatalog_async - */ - updateCatalog( - request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|undefined, {}|undefined - ]>; - updateCatalog( - request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, - callback: Callback< - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.ICatalog, - protos.google.cloud.retail.v2.IUpdateCatalogRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog.name': request.catalog!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCatalog(request, options, callback); - } -/** - * Set a specified branch id as default branch. API methods such as - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search}, - * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct}, - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * will treat requests using "default_branch" to the actual branch id set as - * default. - * - * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as - * default, setting - * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent - * to setting - * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/1`. - * - * Using multiple branches can be useful when developers would like - * to have a staging branch to test and verify for future usage. When it - * becomes ready, developers switch on the staging branch using this API while - * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` - * as {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to - * route the traffic to this staging branch. - * - * CAUTION: If you have live predict/search traffic, switching the default - * branch could potentially cause outages if the ID space of the new branch is - * very different from the old one. - * - * More specifically: - * - * * PredictionService will only return product IDs from branch {newBranch}. - * * SearchService will only return product IDs from branch {newBranch} - * (if branch is not explicitly set). - * * UserEventService will only join events with products from branch - * {newBranch}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.branchId - * The final component of the resource name of a branch. - * - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * - * If there are no sufficient active products in the targeted branch and - * {@link google.cloud.retail.v2.SetDefaultBranchRequest.force|force} is not set, a - * FAILED_PRECONDITION error is returned. - * @param {string} request.note - * Some note on this request, this can be retrieved by - * {@link google.cloud.retail.v2.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} - * before next valid default branch set occurs. - * - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {boolean} request.force - * If set to true, it permits switching to a branch with - * {@link google.cloud.retail.v2.SetDefaultBranchRequest.branch_id|branch_id} even - * if it has no sufficient active products. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/catalog_service.set_default_branch.js - * region_tag:retail_v2_generated_CatalogService_SetDefaultBranch_async - */ - setDefaultBranch( - request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|undefined, {}|undefined - ]>; - setDefaultBranch( - request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.ISetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.setDefaultBranch(request, options, callback); - } -/** - * Get which branch is currently default branch set by - * {@link google.cloud.retail.v2.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} - * method under a specified parent catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2.GetDefaultBranchResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/catalog_service.get_default_branch.js - * region_tag:retail_v2_generated_CatalogService_GetDefaultBranch_async - */ - getDefaultBranch( - request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|undefined, {}|undefined - ]>; - getDefaultBranch( - request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, - callback: Callback< - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2.IGetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.getDefaultBranch(request, options, callback); - } - - /** - * Lists all the {@link google.cloud.retail.v2.Catalog|Catalog}s associated with - * the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless - * of whether or not this location exists, a PERMISSION_DENIED error is - * returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If - * unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2.Catalog}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogs( - request?: protos.google.cloud.retail.v2.IListCatalogsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.ICatalog[], - protos.google.cloud.retail.v2.IListCatalogsRequest|null, - protos.google.cloud.retail.v2.IListCatalogsResponse - ]>; - listCatalogs( - request: protos.google.cloud.retail.v2.IListCatalogsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListCatalogsRequest, - protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2.ICatalog>): void; - listCatalogs( - request: protos.google.cloud.retail.v2.IListCatalogsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListCatalogsRequest, - protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2.ICatalog>): void; - listCatalogs( - request?: protos.google.cloud.retail.v2.IListCatalogsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2.IListCatalogsRequest, - protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2.ICatalog>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2.IListCatalogsRequest, - protos.google.cloud.retail.v2.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2.ICatalog>): - Promise<[ - protos.google.cloud.retail.v2.ICatalog[], - protos.google.cloud.retail.v2.IListCatalogsRequest|null, - protos.google.cloud.retail.v2.IListCatalogsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listCatalogs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless - * of whether or not this location exists, a PERMISSION_DENIED error is - * returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If - * unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2.Catalog} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogsStream( - request?: protos.google.cloud.retail.v2.IListCatalogsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.createStream( - this.innerApiCalls.listCatalogs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listCatalogs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless - * of whether or not this location exists, a PERMISSION_DENIED error is - * returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If - * unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Catalog]{@link google.cloud.retail.v2.Catalog}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/catalog_service.list_catalogs.js - * region_tag:retail_v2_generated_CatalogService_ListCatalogs_async - */ - listCatalogsAsync( - request?: protos.google.cloud.retail.v2.IListCatalogsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.asyncIterate( - this.innerApiCalls['listCatalogs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.catalogServiceStub && !this._terminated) { - return this.catalogServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_client_config.json b/owl-bot-staging/v2/src/v2/catalog_service_client_config.json deleted file mode 100644 index dd5a76fa..00000000 --- a/owl-bot-staging/v2/src/v2/catalog_service_client_config.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.CatalogService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListCatalogs": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCatalog": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "SetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json b/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/catalog_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/completion_service_client.ts b/owl-bot-staging/v2/src/v2/completion_service_client.ts deleted file mode 100644 index b59d288c..00000000 --- a/owl-bot-staging/v2/src/v2/completion_service_client.ts +++ /dev/null @@ -1,701 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/completion_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './completion_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Auto-completion service for retail. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2 - */ -export class CompletionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - completionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CompletionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CompletionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importCompletionDataResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportCompletionDataResponse') as gax.protobuf.Type; - const importCompletionDataMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importCompletionData: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importCompletionDataResponse.decode.bind(importCompletionDataResponse), - importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.CompletionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.completionServiceStub) { - return this.completionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.CompletionService. - this.completionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.CompletionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.CompletionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const completionServiceStubMethods = - ['completeQuery', 'importCompletionData']; - for (const methodName of completionServiceStubMethods) { - const callPromise = this.completionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.completionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Completes the specified prefix with keyword suggestions. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Required. Catalog for which the completion is performed. - * - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.query - * Required. The query used to generate suggestions. - * - * The maximum number of allowed characters is 255. - * @param {string} request.visitorId - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {string[]} request.languageCodes - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see [Tags for - * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - * @param {string} request.deviceType - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * - * Supported formats: - * - * * `UNKNOWN_DEVICE_TYPE` - * - * * `DESKTOP` - * - * * `MOBILE` - * - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - * @param {string} request.dataset - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * {@link google.cloud.retail.v2.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * - * Current supported values: - * - * * user-data - * - * * cloud-retail: - * This option requires enabling auto-learning function first. See - * [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). - * @param {number} request.maxSuggestions - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value {@link |CompletionConfig.max_suggestions}. - * - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2.CompleteQueryResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/completion_service.complete_query.js - * region_tag:retail_v2_generated_CompletionService_CompleteQuery_async - */ - completeQuery( - request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|undefined, {}|undefined - ]>; - completeQuery( - request: protos.google.cloud.retail.v2.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request: protos.google.cloud.retail.v2.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.ICompleteQueryResponse, - protos.google.cloud.retail.v2.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.completeQuery(request, options, callback); - } - -/** - * Bulk import of processed completion dataset. - * - * Request processing is asynchronous. Partial updating is not supported. - * - * The operation is successfully finished only after the imported suggestions - * are indexed successfully and ready for serving. The process takes hours. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog which the suggestions dataset belongs to. - * - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2.CompletionDataInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/completion_service.import_completion_data.js - * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async - */ - importCompletionData( - request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importCompletionData( - request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importCompletionData(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importCompletionData()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/completion_service.import_completion_data.js - * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async - */ - async checkImportCompletionDataProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.completionServiceStub && !this._terminated) { - return this.completionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/completion_service_client_config.json b/owl-bot-staging/v2/src/v2/completion_service_client_config.json deleted file mode 100644 index a6bffad0..00000000 --- a/owl-bot-staging/v2/src/v2/completion_service_client_config.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.CompletionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CompleteQuery": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ImportCompletionData": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/completion_service_proto_list.json b/owl-bot-staging/v2/src/v2/completion_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/completion_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/gapic_metadata.json b/owl-bot-staging/v2/src/v2/gapic_metadata.json deleted file mode 100644 index e2fe1b36..00000000 --- a/owl-bot-staging/v2/src/v2/gapic_metadata.json +++ /dev/null @@ -1,345 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.retail.v2", - "libraryPackage": "@google-cloud/retail", - "services": { - "CatalogService": { - "clients": { - "grpc": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - } - } - }, - "CompletionService": { - "clients": { - "grpc": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - } - } - }, - "PredictionService": { - "clients": { - "grpc": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - } - } - }, - "ProductService": { - "clients": { - "grpc": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - } - } - }, - "SearchService": { - "clients": { - "grpc": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - } - } - }, - "UserEventService": { - "clients": { - "grpc": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/index.ts b/owl-bot-staging/v2/src/v2/index.ts deleted file mode 100644 index 79cde8aa..00000000 --- a/owl-bot-staging/v2/src/v2/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {CatalogServiceClient} from './catalog_service_client'; -export {CompletionServiceClient} from './completion_service_client'; -export {PredictionServiceClient} from './prediction_service_client'; -export {ProductServiceClient} from './product_service_client'; -export {SearchServiceClient} from './search_service_client'; -export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2/src/v2/prediction_service_client.ts b/owl-bot-staging/v2/src/v2/prediction_service_client.ts deleted file mode 100644 index 5e1cd654..00000000 --- a/owl-bot-staging/v2/src/v2/prediction_service_client.ts +++ /dev/null @@ -1,613 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/prediction_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './prediction_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for making recommendation prediction. - * @class - * @memberof v2 - */ -export class PredictionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - predictionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PredictionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PredictionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.PredictionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.predictionServiceStub) { - return this.predictionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.PredictionService. - this.predictionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.PredictionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.PredictionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const predictionServiceStubMethods = - ['predict']; - for (const methodName of predictionServiceStubMethods) { - const callPromise = this.predictionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.predictionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Makes a recommendation prediction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see [Managing - * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - * @param {google.cloud.retail.v2.UserEvent} request.userEvent - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - * - * Don't set - * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} or - * {@link google.cloud.retail.v2.UserInfo.user_id|UserInfo.user_id} to the same - * fixed ID for different users. If you are trying to receive non-personalized - * recommendations (not recommended; this can negatively impact model - * performance), instead set - * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} to a - * random unique ID and leave - * {@link google.cloud.retail.v2.UserInfo.user_id|UserInfo.user_id} unset. - * @param {number} request.pageSize - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - * @param {string} request.pageToken - * The previous PredictResponse.next_page_token. - * @param {string} request.filter - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * - * Examples: - * - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - * @param {boolean} request.validateOnly - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - * @param {number[]} request.params - * Additional domain specific parameters for the predictions. - * - * Allowed values: - * - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - * @param {number[]} request.labels - * The labels applied to a resource must meet the following requirements: - * - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters and cannot be empty. Values can be empty and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * - * See [Google Cloud - * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2.PredictResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/prediction_service.predict.js - * region_tag:retail_v2_generated_PredictionService_Predict_async - */ - predict( - request?: protos.google.cloud.retail.v2.IPredictRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|undefined, {}|undefined - ]>; - predict( - request: protos.google.cloud.retail.v2.IPredictRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request: protos.google.cloud.retail.v2.IPredictRequest, - callback: Callback< - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request?: protos.google.cloud.retail.v2.IPredictRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IPredictResponse, - protos.google.cloud.retail.v2.IPredictRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.predict(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.predictionServiceStub && !this._terminated) { - return this.predictionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/prediction_service_client_config.json b/owl-bot-staging/v2/src/v2/prediction_service_client_config.json deleted file mode 100644 index 9ab95d31..00000000 --- a/owl-bot-staging/v2/src/v2/prediction_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.PredictionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Predict": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json b/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/prediction_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/product_service_client.ts b/owl-bot-staging/v2/src/v2/product_service_client.ts deleted file mode 100644 index 5098955a..00000000 --- a/owl-bot-staging/v2/src/v2/product_service_client.ts +++ /dev/null @@ -1,2223 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/product_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting {@link google.cloud.retail.v2.Product|Product} information - * of the customer's website. - * @class - * @memberof v2 - */ -export class ProductServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ProductServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importProductsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportProductsResponse') as gax.protobuf.Type; - const importProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; - const setInventoryResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.SetInventoryResponse') as gax.protobuf.Type; - const setInventoryMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.SetInventoryMetadata') as gax.protobuf.Type; - const addFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.AddFulfillmentPlacesResponse') as gax.protobuf.Type; - const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; - const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; - const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; - const addLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.AddLocalInventoriesResponse') as gax.protobuf.Type; - const addLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.AddLocalInventoriesMetadata') as gax.protobuf.Type; - const removeLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RemoveLocalInventoriesResponse') as gax.protobuf.Type; - const removeLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductsResponse.decode.bind(importProductsResponse), - importProductsMetadata.decode.bind(importProductsMetadata)), - setInventory: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInventoryResponse.decode.bind(setInventoryResponse), - setInventoryMetadata.decode.bind(setInventoryMetadata)), - addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), - addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), - removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), - removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), - addLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), - addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), - removeLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), - removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.ProductService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.productServiceStub) { - return this.productServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.ProductService. - this.productServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ProductService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.ProductService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const productServiceStubMethods = - ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; - for (const methodName of productServiceStubMethods) { - const callPromise = this.productServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.productServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a {@link google.cloud.retail.v2.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - * @param {google.cloud.retail.v2.Product} request.product - * Required. The {@link google.cloud.retail.v2.Product|Product} to create. - * @param {string} request.productId - * Required. The ID to use for the {@link google.cloud.retail.v2.Product|Product}, - * which will become the final component of the - * {@link google.cloud.retail.v2.Product.name|Product.name}. - * - * If the caller does not have permission to create the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * This field must be unique among all - * {@link google.cloud.retail.v2.Product|Product}s with the same - * {@link google.cloud.retail.v2.CreateProductRequest.parent|parent}. Otherwise, an - * ALREADY_EXISTS error is returned. - * - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/product_service.create_product.js - * region_tag:retail_v2_generated_ProductService_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.retail.v2.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.retail.v2.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.retail.v2.ICreateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.retail.v2.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the requested {@link google.cloud.retail.v2.Product|Product} does not exist, - * a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/product_service.get_product.js - * region_tag:retail_v2_generated_ProductService_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.retail.v2.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.retail.v2.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.retail.v2.IGetProductRequest, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.retail.v2.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Updates a {@link google.cloud.retail.v2.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2.Product} request.product - * Required. The product to update/create. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2.Product|Product} to update does not exist - * and - * {@link google.cloud.retail.v2.UpdateProductRequest.allow_missing|allow_missing} - * is not set, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2.Product|Product} to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * - * The attribute key can be updated by setting the mask path as - * "attributes.${key_name}". If a key name is present in the mask but not in - * the patching product from the request, this key will be deleted after the - * update. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, a new {@link google.cloud.retail.v2.Product|Product} will be created. In - * this situation, `update_mask` is ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/product_service.update_product.js - * region_tag:retail_v2_generated_ProductService_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.retail.v2.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.retail.v2.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.retail.v2.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.retail.v2.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IProduct, - protos.google.cloud.retail.v2.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Deletes a {@link google.cloud.retail.v2.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to delete the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2.Product|Product} to delete does not exist, - * a NOT_FOUND error is returned. - * - * The {@link google.cloud.retail.v2.Product|Product} to delete can neither be a - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product} member nor a - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product} with more than one - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variants}. Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * All inventory information for the named - * {@link google.cloud.retail.v2.Product|Product} will be deleted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/product_service.delete_product.js - * region_tag:retail_v2_generated_ProductService_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.retail.v2.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.retail.v2.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.retail.v2.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.retail.v2.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } - -/** - * Bulk import of multiple {@link google.cloud.retail.v2.Product|Product}s. - * - * Request processing may be synchronous. - * Non-existing items are created. - * - * Note that it is possible for a subset of the - * {@link google.cloud.retail.v2.Product|Product}s to be successfully updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - * @param {string} request.requestId - * Deprecated. This field has no effect. - * @param {google.cloud.retail.v2.ProductInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - * @param {google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode} request.reconciliationMode - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * {@link google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. - * @param {string} request.notificationPubsubTopic - * Full Pub/Sub topic name for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has - * to be within the same project as - * {@link google.cloud.retail.v2.ImportProductsRequest.parent|ImportProductsRequest.parent}. - * Make sure that both - * `cloud-retail-customer-data-access@system.gserviceaccount.com` and - * `service-@gcp-sa-retail.iam.gserviceaccount.com` - * have the `pubsub.topics.publish` IAM permission on the topic. - * - * Only supported when - * {@link google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} - * is set to `FULL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.import_products.js - * region_tag:retail_v2_generated_ProductService_ImportProducts_async - */ - importProducts( - request?: protos.google.cloud.retail.v2.IImportProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProducts( - request: protos.google.cloud.retail.v2.IImportProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request: protos.google.cloud.retail.v2.IImportProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request?: protos.google.cloud.retail.v2.IImportProductsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.import_products.js - * region_tag:retail_v2_generated_ProductService_ImportProducts_async - */ - async checkImportProductsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates inventory information for a - * {@link google.cloud.retail.v2.Product|Product} while respecting the last update - * timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, updates are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * When inventory is updated with - * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct}, the - * specified inventory field value(s) will overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update time for the specified inventory fields will be overwritten to the - * time of the - * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} or - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} - * request. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2.CreateProductRequest.product|CreateProductRequest.product}, - * then any pre-existing inventory information for this product will be used. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, - * then any existing inventory information will be preserved. - * - * Pre-existing inventory information can only be updated with - * {@link google.cloud.retail.v2.ProductService.SetInventory|SetInventory}, - * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, - * and - * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2.Product} request.inventory - * Required. The inventory information to update. The allowable fields to - * update are: - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} - * The updated inventory fields must be specified in - * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. - * - * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2.Product|Product} named in - * {@link google.cloud.retail.v2.Product.name|Product.name}, regardless of whether - * or not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2.Product|Product} to update does not have - * existing inventory information, the provided inventory information will be - * inserted. - * - * If the {@link google.cloud.retail.v2.Product|Product} to update has existing - * inventory information, the provided inventory information will be merged - * while respecting the last update time for each inventory field, using the - * provided or default value for - * {@link google.cloud.retail.v2.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. - * - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} - * - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types to clear in - * {@link |SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} - * - * The last update time is recorded for the following inventory fields: - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} - * - * If a full overwrite of inventory information while ignoring timestamps is - * needed, {@link |UpdateProduct} should be invoked instead. - * @param {google.protobuf.FieldMask} request.setMask - * Indicates which inventory fields in the provided - * {@link google.cloud.retail.v2.Product|Product} to update. - * - * At least one field must be provided. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.setTime - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} with name - * {@link google.cloud.retail.v2.Product.name|Product.name} is not found, the - * inventory update will still be processed and retained for at most 1 day - * until the {@link google.cloud.retail.v2.Product|Product} is created. If set to - * false, a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.set_inventory.js - * region_tag:retail_v2_generated_ProductService_SetInventory_async - */ - setInventory( - request?: protos.google.cloud.retail.v2.ISetInventoryRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInventory( - request: protos.google.cloud.retail.v2.ISetInventoryRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request: protos.google.cloud.retail.v2.ISetInventoryRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request?: protos.google.cloud.retail.v2.ISetInventoryRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'inventory.name': request.inventory!.name || '', - }); - this.initialize(); - return this.innerApiCalls.setInventory(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInventory()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.set_inventory.js - * region_tag:retail_v2_generated_ProductService_SetInventory_async - */ - async checkSetInventoryProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally adds place IDs to - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the added place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}, such as - * the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}. Duplicate - * IDs will be automatically ignored. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * If the total number of place IDs exceeds 2000 for this - * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type} after - * adding, then the update will be rejected. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, the fulfillment information will still be processed and retained for - * at most 1 day and processed once the - * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a - * NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.add_fulfillment_places.js - * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async - */ - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.add_fulfillment_places.js - * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async - */ - async checkAddFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally removes place IDs from a - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the removed place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to - * {@link google.cloud.retail.v2.FulfillmentInfo.type|Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}, such as - * the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, the fulfillment information will still be processed and retained for - * at most 1 day and processed once the - * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a - * NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js - * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async - */ - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js - * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async - */ - async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates local inventory information for a - * {@link google.cloud.retail.v2.Product|Product} at a list of places, while - * respecting the last update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2.Product|Product} to exist before updating - * inventory information. If the request is valid, the update will be enqueued - * and processed downstream. As a consequence, when a response is returned, - * updates are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} has no - * effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * @param {number[]} request.localInventories - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - * @param {google.protobuf.FieldMask} request.addMask - * Indicates which inventory fields in the provided list of - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory} to update. The - * field is updated to the provided value. - * - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, the local inventory will still be processed and retained for at most - * 1 day and processed once the {@link google.cloud.retail.v2.Product|Product} is - * created. If set to false, a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.add_local_inventories.js - * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async - */ - addLocalInventories( - request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addLocalInventories( - request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.add_local_inventories.js - * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async - */ - async checkAddLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Remove local inventory information for a - * {@link google.cloud.retail.v2.Product|Product} at a list of places at a removal - * timestamp. - * - * This process is asynchronous. If the request is valid, the removal will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, removals are not immediately manifested in the - * {@link google.cloud.retail.v2.Product|Product} queried by - * {@link google.cloud.retail.v2.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link google.cloud.retail.v2.ProductService.CreateProduct|CreateProduct} and - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|UpdateProduct} has no - * effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, - * such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it - * exists, a PERMISSION_DENIED error is returned. - * @param {string[]} request.placeIds - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not - * found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a - * NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.remove_local_inventories.js - * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async - */ - removeLocalInventories( - request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeLocalInventories( - request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/product_service.remove_local_inventories.js - * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async - */ - async checkRemoveLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.retail.v2.Product|Product}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of - * whether or not this branch exists, a PERMISSION_DENIED error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. - * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2.Product|Product}s sharing the same - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. - * For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product} or - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error - * is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the - * responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2.Product.name|Product.name} - * * {@link google.cloud.retail.v2.Product.id|Product.id} - * * {@link google.cloud.retail.v2.Product.title|Product.title} - * * {@link google.cloud.retail.v2.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2.Product.images|Product.images} - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no - * matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.retail.v2.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.retail.v2.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IProduct[], - protos.google.cloud.retail.v2.IListProductsRequest|null, - protos.google.cloud.retail.v2.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.retail.v2.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListProductsRequest, - protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2.IProduct>): void; - listProducts( - request: protos.google.cloud.retail.v2.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListProductsRequest, - protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2.IProduct>): void; - listProducts( - request?: protos.google.cloud.retail.v2.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2.IListProductsRequest, - protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2.IListProductsRequest, - protos.google.cloud.retail.v2.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2.IProduct>): - Promise<[ - protos.google.cloud.retail.v2.IProduct[], - protos.google.cloud.retail.v2.IListProductsRequest|null, - protos.google.cloud.retail.v2.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of - * whether or not this branch exists, a PERMISSION_DENIED error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. - * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2.Product|Product}s sharing the same - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. - * For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product} or - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error - * is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the - * responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2.Product.name|Product.name} - * * {@link google.cloud.retail.v2.Product.id|Product.id} - * * {@link google.cloud.retail.v2.Product.title|Product.title} - * * {@link google.cloud.retail.v2.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2.Product.images|Product.images} - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no - * matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.retail.v2.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of - * whether or not this branch exists, a PERMISSION_DENIED error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. - * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2.Product|Product}s sharing the same - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. - * For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2.Product|Product} or - * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error - * is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the - * responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2.Product.name|Product.name} - * * {@link google.cloud.retail.v2.Product.id|Product.id} - * * {@link google.cloud.retail.v2.Product.title|Product.title} - * * {@link google.cloud.retail.v2.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2.Product.images|Product.images} - * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no - * matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.retail.v2.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/product_service.list_products.js - * region_tag:retail_v2_generated_ProductService_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.retail.v2.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.productServiceStub && !this._terminated) { - return this.productServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/product_service_client_config.json b/owl-bot-staging/v2/src/v2/product_service_client_config.json deleted file mode 100644 index 32245ac6..00000000 --- a/owl-bot-staging/v2/src/v2/product_service_client_config.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.ProductService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "GetProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ListProducts": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "UpdateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "DeleteProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportProducts": { - "timeout_millis": 300000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "SetInventory": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/product_service_proto_list.json b/owl-bot-staging/v2/src/v2/product_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/product_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/search_service_client.ts b/owl-bot-staging/v2/src/v2/search_service_client.ts deleted file mode 100644 index c2886df0..00000000 --- a/owl-bot-staging/v2/src/v2/search_service_client.ts +++ /dev/null @@ -1,1324 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/search_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './search_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2 - */ -export class SearchServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - searchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SearchServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SearchServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - search: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.SearchService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.searchServiceStub) { - return this.searchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.SearchService. - this.searchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.SearchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.SearchService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const searchServiceStubMethods = - ['search']; - for (const methodName of searchServiceStubMethods) { - const callPromise = this.searchServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.searchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Performs a search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * - * If this field is empty, the request is considered a category browsing - * request and returned results are based on - * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and - * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to a reasonable value. The maximum allowed value is - * 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must - * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - * error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} - * is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for - * more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it - * unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both {@link |ServingConfig.boost_control_ids} and - * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} - * are set, the boost conditions from both places are evaluated. If a search - * request matches multiple boost conditions, the final boost score is equal - * to the sum of the boost scores from all matched boost conditions. - * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s attributes, - * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The - * attributes from all the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {number[]} request.labels - * The labels applied to a resource must meet the following requirements: - * - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters and cannot be empty. Values can be empty and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * - * See [Google Cloud - * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - search( - request?: protos.google.cloud.retail.v2.ISearchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2.ISearchRequest|null, - protos.google.cloud.retail.v2.ISearchResponse - ]>; - search( - request: protos.google.cloud.retail.v2.ISearchRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2.ISearchRequest, - protos.google.cloud.retail.v2.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): void; - search( - request: protos.google.cloud.retail.v2.ISearchRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2.ISearchRequest, - protos.google.cloud.retail.v2.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): void; - search( - request?: protos.google.cloud.retail.v2.ISearchRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2.ISearchRequest, - protos.google.cloud.retail.v2.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2.SearchResponse.ISearchResult>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2.ISearchRequest, - protos.google.cloud.retail.v2.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2.SearchResponse.ISearchResult>): - Promise<[ - protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2.ISearchRequest|null, - protos.google.cloud.retail.v2.ISearchResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.search(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * - * If this field is empty, the request is considered a category browsing - * request and returned results are based on - * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and - * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to a reasonable value. The maximum allowed value is - * 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must - * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - * error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} - * is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for - * more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it - * unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both {@link |ServingConfig.boost_control_ids} and - * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} - * are set, the boost conditions from both places are evaluated. If a search - * request matches multiple boost conditions, the final boost score is equal - * to the sum of the boost scores from all matched boost conditions. - * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s attributes, - * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The - * attributes from all the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {number[]} request.labels - * The labels applied to a resource must meet the following requirements: - * - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters and cannot be empty. Values can be empty and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * - * See [Google Cloud - * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - searchStream( - request?: protos.google.cloud.retail.v2.ISearchRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.createStream( - this.innerApiCalls.search as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `search`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * - * If this field is empty, the request is considered a category browsing - * request and returned results are based on - * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and - * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If - * unspecified, defaults to a reasonable value. The maximum allowed value is - * 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must - * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT - * error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} - * is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for - * more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it - * unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both {@link |ServingConfig.boost_control_ids} and - * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} - * are set, the boost conditions from both places are evaluated. If a search - * request matches multiple boost conditions, the final boost score is equal - * to the sum of the boost scores from all matched boost conditions. - * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s attributes, - * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The - * attributes from all the matching - * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2.Product|Product}s or - * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} - * map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {number[]} request.labels - * The labels applied to a resource must meet the following requirements: - * - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters and cannot be empty. Values can be empty and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * - * See [Google Cloud - * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/search_service.search.js - * region_tag:retail_v2_generated_SearchService_Search_async - */ - searchAsync( - request?: protos.google.cloud.retail.v2.ISearchRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.asyncIterate( - this.innerApiCalls['search'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.searchServiceStub && !this._terminated) { - return this.searchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/search_service_client_config.json b/owl-bot-staging/v2/src/v2/search_service_client_config.json deleted file mode 100644 index 5132c12d..00000000 --- a/owl-bot-staging/v2/src/v2/search_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.SearchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Search": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/search_service_proto_list.json b/owl-bot-staging/v2/src/v2/search_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/search_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/src/v2/user_event_service_client.ts b/owl-bot-staging/v2/src/v2/user_event_service_client.ts deleted file mode 100644 index 18b3688e..00000000 --- a/owl-bot-staging/v2/src/v2/user_event_service_client.ts +++ /dev/null @@ -1,966 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/user_event_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './user_event_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting end user actions on the customer website. - * @class - * @memberof v2 - */ -export class UserEventServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - userEventServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of UserEventServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof UserEventServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const purgeUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.PurgeUserEventsResponse') as gax.protobuf.Type; - const purgeUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.PurgeMetadata') as gax.protobuf.Type; - const importUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportUserEventsResponse') as gax.protobuf.Type; - const importUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.ImportMetadata') as gax.protobuf.Type; - const rejoinUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RejoinUserEventsResponse') as gax.protobuf.Type; - const rejoinUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.RejoinUserEventsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - purgeUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), - purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), - importUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importUserEventsResponse.decode.bind(importUserEventsResponse), - importUserEventsMetadata.decode.bind(importUserEventsMetadata)), - rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), - rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.UserEventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.userEventServiceStub) { - return this.userEventServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.UserEventService. - this.userEventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.UserEventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.UserEventService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const userEventServiceStubMethods = - ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; - for (const methodName of userEventServiceStubMethods) { - const callPromise = this.userEventServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.userEventServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Writes a single user event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2.UserEvent} request.userEvent - * Required. User event to write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2.UserEvent}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.write_user_event.js - * region_tag:retail_v2_generated_UserEventService_WriteUserEvent_async - */ - writeUserEvent( - request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|undefined, {}|undefined - ]>; - writeUserEvent( - request: protos.google.cloud.retail.v2.IWriteUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request: protos.google.cloud.retail.v2.IWriteUserEventRequest, - callback: Callback< - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IUserEvent, - protos.google.cloud.retail.v2.IWriteUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.writeUserEvent(request, options, callback); - } -/** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Retail API JavaScript pixel and Google Tag - * Manager. Users should not call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {string} request.userEvent - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - * @param {string} request.uri - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - * @param {number} request.ets - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.collect_user_event.js - * region_tag:retail_v2_generated_UserEventService_CollectUserEvent_async - */ - collectUserEvent( - request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|undefined, {}|undefined - ]>; - collectUserEvent( - request: protos.google.cloud.retail.v2.ICollectUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request: protos.google.cloud.retail.v2.ICollectUserEventRequest, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2.ICollectUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.collectUserEvent(request, options, callback); - } - -/** - * Deletes permanently all user events specified by the filter provided. - * Depending on the number of events specified by the filter, this operation - * could take hours or days to complete. To test a filter, use the list - * command first. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - * @param {string} request.filter - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * - * * `eventType`: Double quoted - * {@link google.cloud.retail.v2.UserEvent.event_type|UserEvent.event_type} string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * - * Examples: - * - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * - * The filtering fields are assumed to have an implicit AND. - * @param {boolean} request.force - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.purge_user_events.js - * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async - */ - purgeUserEvents( - request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeUserEvents( - request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.purgeUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.purge_user_events.js - * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async - */ - async checkPurgeUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. `projects/1234/locations/global/catalogs/default_catalog` - * @param {google.cloud.retail.v2.UserEventInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.import_user_events.js - * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async - */ - importUserEvents( - request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importUserEvents( - request: protos.google.cloud.retail.v2.IImportUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request: protos.google.cloud.retail.v2.IImportUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.import_user_events.js - * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async - */ - async checkImportUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a user event rejoin operation with latest product catalog. Events - * will not be annotated with detailed product information if product is - * missing from the catalog at the time the user event is ingested, and these - * events are stored as unjoined events with a limited usage on training and - * serving. This method can be used to start a join operation on specified - * events with latest version of product catalog. It can also be used to - * correct events joined with the wrong product catalog. A rejoin operation - * can take hours or days to complete. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js - * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async - */ - rejoinUserEvents( - request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rejoinUserEvents( - request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.rejoinUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rejoinUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js - * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async - */ - async checkRejoinUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.userEventServiceStub && !this._terminated) { - return this.userEventServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/user_event_service_client_config.json b/owl-bot-staging/v2/src/v2/user_event_service_client_config.json deleted file mode 100644 index a3938b37..00000000 --- a/owl-bot-staging/v2/src/v2/user_event_service_client_config.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.UserEventService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "WriteUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "CollectUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "PurgeUserEvents": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportUserEvents": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "RejoinUserEvents": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json b/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json deleted file mode 100644 index dd7dfb7a..00000000 --- a/owl-bot-staging/v2/src/v2/user_event_service_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2/catalog.proto", - "../../protos/google/cloud/retail/v2/catalog_service.proto", - "../../protos/google/cloud/retail/v2/common.proto", - "../../protos/google/cloud/retail/v2/completion_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/prediction_service.proto", - "../../protos/google/cloud/retail/v2/product.proto", - "../../protos/google/cloud/retail/v2/product_service.proto", - "../../protos/google/cloud/retail/v2/promotion.proto", - "../../protos/google/cloud/retail/v2/purge_config.proto", - "../../protos/google/cloud/retail/v2/search_service.proto", - "../../protos/google/cloud/retail/v2/user_event.proto", - "../../protos/google/cloud/retail/v2/user_event_service.proto" -] diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index ffbb2218..00000000 --- a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const retail = require('@google-cloud/retail'); - -function main() { - const catalogServiceClient = new retail.CatalogServiceClient(); - const completionServiceClient = new retail.CompletionServiceClient(); - const predictionServiceClient = new retail.PredictionServiceClient(); - const productServiceClient = new retail.ProductServiceClient(); - const searchServiceClient = new retail.SearchServiceClient(); - const userEventServiceClient = new retail.UserEventServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 285edd82..00000000 --- a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts +++ /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. ** - -import {CatalogServiceClient, CompletionServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, UserEventServiceClient} from '@google-cloud/retail'; - -// check that the client class type name can be used -function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { - client.close(); -} -function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { - client.close(); -} -function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { - client.close(); -} -function doStuffWithProductServiceClient(client: ProductServiceClient) { - client.close(); -} -function doStuffWithSearchServiceClient(client: SearchServiceClient) { - client.close(); -} -function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const catalogServiceClient = new CatalogServiceClient(); - doStuffWithCatalogServiceClient(catalogServiceClient); - // check that the client instance can be created - const completionServiceClient = new CompletionServiceClient(); - doStuffWithCompletionServiceClient(completionServiceClient); - // check that the client instance can be created - const predictionServiceClient = new PredictionServiceClient(); - doStuffWithPredictionServiceClient(predictionServiceClient); - // check that the client instance can be created - const productServiceClient = new ProductServiceClient(); - doStuffWithProductServiceClient(productServiceClient); - // check that the client instance can be created - const searchServiceClient = new SearchServiceClient(); - doStuffWithSearchServiceClient(searchServiceClient); - // check that the client instance can be created - const userEventServiceClient = new UserEventServiceClient(); - doStuffWithUserEventServiceClient(userEventServiceClient); -} - -main(); diff --git a/owl-bot-staging/v2/system-test/install.ts b/owl-bot-staging/v2/system-test/install.ts deleted file mode 100644 index 8ec45222..00000000 --- a/owl-bot-staging/v2/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/v2/test/gapic_catalog_service_v2.ts b/owl-bot-staging/v2/test/gapic_catalog_service_v2.ts deleted file mode 100644 index 8a1bf5ac..00000000 --- a/owl-bot-staging/v2/test/gapic_catalog_service_v2.ts +++ /dev/null @@ -1,903 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as catalogserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2.CatalogServiceClient', () => { - it('has servicePath', () => { - const servicePath = catalogserviceModule.v2.CatalogServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = catalogserviceModule.v2.CatalogServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = catalogserviceModule.v2.CatalogServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new catalogserviceModule.v2.CatalogServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - await client.initialize(); - assert(client.catalogServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.catalogServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('updateCatalog', () => { - it('invokes updateCatalog without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); - const [response] = await client.updateCatalog(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCatalog( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.ICatalog|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCatalog with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCatalog(request), expectedError); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog with closed client', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCatalog(request), expectedError); - }); - }); - - describe('setDefaultBranch', () => { - it('invokes setDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.setDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setDefaultBranch( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setDefaultBranch(request), expectedError); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setDefaultBranch(request), expectedError); - }); - }); - - describe('getDefaultBranch', () => { - it('invokes getDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.getDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDefaultBranch( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IGetDefaultBranchResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDefaultBranch(request), expectedError); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDefaultBranch(request), expectedError); - }); - }); - - describe('listCatalogs', () => { - it('invokes listCatalogs without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); - const [response] = await client.listCatalogs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogs without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCatalogs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.ICatalog[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listCatalogs with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCatalogs(request), expectedError); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogsStream without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - ]; - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listCatalogsStream with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), - ]; - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2.ICatalog[] = []; - const iterable = client.listCatalogsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCatalogsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2.ICatalog[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_completion_service_v2.ts b/owl-bot-staging/v2/test/gapic_completion_service_v2.ts deleted file mode 100644 index c15e5c3f..00000000 --- a/owl-bot-staging/v2/test/gapic_completion_service_v2.ts +++ /dev/null @@ -1,503 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as completionserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2.CompletionServiceClient', () => { - it('has servicePath', () => { - const servicePath = completionserviceModule.v2.CompletionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = completionserviceModule.v2.CompletionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = completionserviceModule.v2.CompletionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new completionserviceModule.v2.CompletionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - await client.initialize(); - assert(client.completionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.completionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery without error using callback', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes completeQuery with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery with closed client', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CompleteQueryRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.completeQuery(request), expectedError); - }); - }); - - describe('importCompletionData', () => { - it('invokes importCompletionData without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); - const [operation] = await client.importCompletionData(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData without error using callback', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importCompletionData( - request, - (err?: Error|null, - result?: LROperation|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.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importCompletionData with call error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importCompletionData(request), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData with LRO error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importCompletionData(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportCompletionDataProgress without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportCompletionDataProgress with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts b/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts deleted file mode 100644 index efa20c2b..00000000 --- a/owl-bot-staging/v2/test/gapic_prediction_service_v2.ts +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as predictionserviceModule from '../src'; - -import {protobuf} 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('v2.PredictionServiceClient', () => { - it('has servicePath', () => { - const servicePath = predictionserviceModule.v2.PredictionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = predictionserviceModule.v2.PredictionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = predictionserviceModule.v2.PredictionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new predictionserviceModule.v2.PredictionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - await client.initialize(); - assert(client.predictionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.predictionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('predict', () => { - it('invokes predict without error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCall(expectedResponse); - const [response] = await client.predict(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict without error using callback', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.predict( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IPredictResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes predict with error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.predict(request), expectedError); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict with closed client', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PredictRequest()); - request.placement = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.predict(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_product_service_v2.ts b/owl-bot-staging/v2/test/gapic_product_service_v2.ts deleted file mode 100644 index aafd946a..00000000 --- a/owl-bot-staging/v2/test/gapic_product_service_v2.ts +++ /dev/null @@ -1,1846 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as productserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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('v2.ProductServiceClient', () => { - it('has servicePath', () => { - const servicePath = productserviceModule.v2.ProductServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productserviceModule.v2.ProductServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productserviceModule.v2.ProductServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productserviceModule.v2.ProductServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productserviceModule.v2.ProductServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - await client.initialize(); - assert(client.productServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CreateProductRequest()); - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.GetProductRequest()); - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('importProducts', () => { - it('invokes importProducts without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProducts( - request, - (err?: Error|null, - result?: LROperation|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.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProducts with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProducts(request), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductsProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductsProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInventory', () => { - it('invokes setInventory without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInventory(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInventory( - request, - (err?: Error|null, - result?: LROperation|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.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setInventory with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInventory(request), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInventory(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkSetInventoryProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInventoryProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInventoryProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addFulfillmentPlaces', () => { - it('invokes addFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeFulfillmentPlaces', () => { - it('invokes removeFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addLocalInventories', () => { - it('invokes addLocalInventories without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.addLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addLocalInventories with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addLocalInventories(request), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeLocalInventories', () => { - it('invokes removeLocalInventories without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeLocalInventories with call error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeLocalInventories(request), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - 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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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.retail.v2.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.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 productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.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.retail.v2.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_search_service_v2.ts b/owl-bot-staging/v2/test/gapic_search_service_v2.ts deleted file mode 100644 index 44857ae4..00000000 --- a/owl-bot-staging/v2/test/gapic_search_service_v2.ts +++ /dev/null @@ -1,570 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as searchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2.SearchServiceClient', () => { - it('has servicePath', () => { - const servicePath = searchserviceModule.v2.SearchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = searchserviceModule.v2.SearchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = searchserviceModule.v2.SearchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new searchserviceModule.v2.SearchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - await client.initialize(); - assert(client.searchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.searchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('search', () => { - it('invokes search without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCall(expectedResponse); - const [response] = await client.search(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes search without error using callback', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.search( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes search with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchStream without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes searchStream with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedError = new Error('expected'); - client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = []; - const iterable = client.searchAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts b/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts deleted file mode 100644 index 2cb56664..00000000 --- a/owl-bot-staging/v2/test/gapic_user_event_service_v2.ts +++ /dev/null @@ -1,888 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as usereventserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2.UserEventServiceClient', () => { - it('has servicePath', () => { - const servicePath = usereventserviceModule.v2.UserEventServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = usereventserviceModule.v2.UserEventServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = usereventserviceModule.v2.UserEventServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new usereventserviceModule.v2.UserEventServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - await client.initialize(); - assert(client.userEventServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.userEventServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('writeUserEvent', () => { - it('invokes writeUserEvent without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.writeUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.writeUserEvent( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IUserEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes writeUserEvent with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.WriteUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.writeUserEvent(request), expectedError); - }); - }); - - describe('collectUserEvent', () => { - it('invokes collectUserEvent without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.collectUserEvent( - request, - (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes collectUserEvent with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.CollectUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.collectUserEvent(request), expectedError); - }); - }); - - describe('purgeUserEvents', () => { - it('invokes purgeUserEvents without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeUserEvents with call error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeUserEvents(request), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importUserEvents', () => { - it('invokes importUserEvents without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.importUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importUserEvents with call error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rejoinUserEvents', () => { - it('invokes rejoinUserEvents without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejoinUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejoinUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes rejoinUserEvents with call error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejoinUserEvents(request), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejoinUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRejoinUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRejoinUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/tsconfig.json b/owl-bot-staging/v2/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v2/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/v2/webpack.config.js b/owl-bot-staging/v2/webpack.config.js deleted file mode 100644 index f2c58f25..00000000 --- a/owl-bot-staging/v2/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: 'CatalogService', - filename: './catalog-service.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v2alpha/.eslintignore b/owl-bot-staging/v2alpha/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v2alpha/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v2alpha/.eslintrc.json b/owl-bot-staging/v2alpha/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v2alpha/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v2alpha/.gitignore b/owl-bot-staging/v2alpha/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v2alpha/.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/v2alpha/.jsdoc.js b/owl-bot-staging/v2alpha/.jsdoc.js deleted file mode 100644 index 19729810..00000000 --- a/owl-bot-staging/v2alpha/.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/retail', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v2alpha/.mocharc.js b/owl-bot-staging/v2alpha/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v2alpha/.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/v2alpha/.prettierrc.js b/owl-bot-staging/v2alpha/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v2alpha/.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/v2alpha/README.md b/owl-bot-staging/v2alpha/README.md deleted file mode 100644 index 822c4573..00000000 --- a/owl-bot-staging/v2alpha/README.md +++ /dev/null @@ -1 +0,0 @@ -Retail: Nodejs Client diff --git a/owl-bot-staging/v2alpha/linkinator.config.json b/owl-bot-staging/v2alpha/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v2alpha/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/v2alpha/package.json b/owl-bot-staging/v2alpha/package.json deleted file mode 100644 index 94071ee3..00000000 --- a/owl-bot-staging/v2alpha/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@google-cloud/retail", - "version": "0.1.0", - "description": "Retail client for Node.js", - "repository": "googleapis/nodejs-retail", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google retail", - "retail", - "catalog service", - "completion service", - "control service", - "prediction service", - "product service", - "search service", - "serving config service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto deleted file mode 100644 index 9b3d8cb0..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/import_config.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Configures what level the product should be uploaded with regards to -// how users will be send events and how predictions will be made. -message ProductLevelConfig { - // The type of [Product][google.cloud.retail.v2alpha.Product]s allowed to be - // ingested into the catalog. Acceptable values are: - // - // * `primary` (default): You can ingest - // [Product][google.cloud.retail.v2alpha.Product]s of all types. When - // ingesting a [Product][google.cloud.retail.v2alpha.Product], its type will - // default to - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // if unset. - // * `variant`: You can only ingest - // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s. - // This means - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] - // cannot be empty. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `variant` and - // [merchant_center_product_id_field][google.cloud.retail.v2alpha.ProductLevelConfig.merchant_center_product_id_field] - // is `itemGroupId`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string ingestion_product_type = 1; - - // Which field of [Merchant Center - // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be - // imported as [Product.id][google.cloud.retail.v2alpha.Product.id]. - // Acceptable values are: - // - // * `offerId` (default): Import `offerId` as the product ID. - // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail - // API will choose one item from the ones with the same `itemGroupId`, and - // use it to represent the item group. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `itemGroupId` and - // [ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] - // is `variant`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string merchant_center_product_id_field = 2; -} - -// Catalog level attribute config for an attribute. For example, if customers -// want to enable/disable facet for a specific attribute. -message CatalogAttribute { - // The type of an attribute. - enum AttributeType { - // The type of the attribute is unknown. - // - // Used when type cannot be derived from attribute that is not - // [in_use][google.cloud.retail.v2alpha.CatalogAttribute.in_use]. - UNKNOWN = 0; - - // Textual attribute. - TEXTUAL = 1; - - // Numerical attribute. - NUMERICAL = 2; - } - - // The status of the indexable option of a catalog attribute. - enum IndexableOption { - // Value used when unset. Defaults to - // [INDEXABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. - INDEXABLE_OPTION_UNSPECIFIED = 0; - - // Indexable option enabled for an attribute. - INDEXABLE_ENABLED = 1; - - // Indexable option disabled for an attribute. - INDEXABLE_DISABLED = 2; - } - - // The status of the dynamic facetable option of a catalog attribute. - enum DynamicFacetableOption { - // Value used when unset. Defaults to - // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. - DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; - - // Dynamic facetable option enabled for an attribute. - DYNAMIC_FACETABLE_ENABLED = 1; - - // Dynamic facetable option disabled for an attribute. - DYNAMIC_FACETABLE_DISABLED = 2; - } - - // The status of the searchable option of a catalog attribute. - enum SearchableOption { - // Value used when unset. Defaults to - // [SEARCHABLE_DISABLED][google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. - SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Searchable option enabled for an attribute. - SEARCHABLE_ENABLED = 1; - - // Searchable option disabled for an attribute. - SEARCHABLE_DISABLED = 2; - } - - // Required. Attribute name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Output only. Indicates whether this attribute has been used by any - // products. `True` if at least one - // [Product][google.cloud.retail.v2alpha.Product] is using this attribute in - // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. - // Otherwise, this field is `False`. - // - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] can be - // pre-loaded by using [AddCatalogAttribute][], [ImportCatalogAttributes][], - // or [UpdateAttributesConfig][] APIs. This field is `False` for pre-loaded - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s. - // - // Only [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that - // are not in use by products can be deleted. - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that are - // in use by products cannot be deleted; however, their configuration - // properties will reset to default values upon removal request. - // - // After catalog changes, it takes about 10 minutes for this field to update. - bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The type of this attribute. This is derived from the attribute - // in [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. - AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values - // are indexed so that it can be filtered, faceted, or boosted in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - IndexableOption indexable_option = 5; - - // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic - // facet. Could only be DYNAMIC_FACETABLE_DISABLED if - // [CatalogAttribute.indexable_option][google.cloud.retail.v2alpha.CatalogAttribute.indexable_option] - // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. - DynamicFacetableOption dynamic_facetable_option = 6; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values - // are searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values - // will not be searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], - // as there are no text values associated to numerical attributes. - SearchableOption searchable_option = 7; -} - -// Catalog level attribute config. -message AttributesConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/AttributesConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" - }; - - // Required. Immutable. The fully qualified resource name of the attribute - // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Enable attribute(s) config at catalog level. - // For example, indexable, dynamic_facetable, or searchable for each - // attribute. - // - // The key is catalog attribute's name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - // - // The maximum number of catalog attributes allowed in a request is 1000. - map catalog_attributes = 2; - - // Output only. The - // [AttributeConfigLevel][google.cloud.retail.v2alpha.AttributeConfigLevel] - // used for this catalog. - AttributeConfigLevel attribute_config_level = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Catalog level autocomplete config for customers to customize autocomplete -// feature's settings. -message CompletionConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/CompletionConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" - }; - - // Required. Immutable. Fully qualified name - // `projects/*/locations/*/catalogs/*/completionConfig` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Specifies the matching order for autocomplete suggestions, e.g., a query - // consisting of 'sh' with 'out-of-order' specified would suggest "women's - // shoes", whereas a query of 'red s' with 'exact-prefix' specified would - // suggest "red shoes". Currently supported values: - // - // * 'out-of-order' - // * 'exact-prefix' - // - // Default value: 'exact-prefix'. - string matching_order = 2; - - // The maximum number of autocomplete suggestions returned per term. The - // maximum allowed max suggestions is 20. Default value is 20. If left unset - // or set to 0, then will fallback to default value. - int32 max_suggestions = 3; - - // The minimum number of characters needed to be typed in order to get - // suggestions. Default value is 2. If left unset or set to 0, then will - // fallback to default value. - int32 min_prefix_length = 4; - - // If set to true, the auto learning function is enabled. Auto learning uses - // user data to generate suggestions using ML techniques. Default value is - // false. Only after enabling auto learning can users use `cloud-retail` - // data in - // [CompleteQueryRequest][google.cloud.retail.v2alpha.CompleteQueryRequest]. - bool auto_learning = 11; - - // Output only. The input config for the import of the source data that - // contains the autocomplete phrases uploaded by the customer. - CompletionDataInputConfig suggestions_input_config = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the LRO corresponding to the latest suggestion terms - // list import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_suggestions_import_operation = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The input config for the import of the source data that - // contains the / autocomplete denylist phrases uploaded by the customer. - CompletionDataInputConfig denylist_input_config = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. LRO corresponding to the latest denylist import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_denylist_import_operation = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The input config for the import of the source data that - // contains the autocomplete allowlist phrases uploaded by the customer. - CompletionDataInputConfig allowlist_input_config = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. LRO corresponding to the latest allowlist import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_allowlist_import_operation = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Represents a link between a Merchant Center account and a branch. -// Once a link is established, products from the linked merchant center account -// will be streamed to the linked branch. -message MerchantCenterLink { - // Required. The linked [Merchant center account - // id](https://developers.google.com/shopping-content/guides/accountstatuses). - // The account must be a standalone account or a sub-account of a MCA. - int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch id (e.g. 0/1/2) within this catalog that products from - // merchant_center_account_id are streamed to. When updating this field, an - // empty value will use the currently configured default branch. However, - // changing the default branch later on won't change the linked branch here. - // - // A single branch id can only have one linked merchant center account id. - string branch_id = 2; - - // String representing the destination to import for, all if left empty. - // List of possible values can be found here. - // [https://support.google.com/merchants/answer/7501026] - // List of allowed string values: - // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory - // _ads", "Free_listings", "Free_local_listings" - // NOTE: The string values are case sensitive. - repeated string destinations = 3; - - // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 - // code. List of values can be found - // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) - // under the `region` tag. If left blank no region filtering will be - // performed. - // - // Example value: `US`. - string region_code = 4; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // ISO 639-1. - // - // This specifies the language of offers in Merchant Center that will be - // accepted. If empty no language filtering will be performed. - // - // Example value: `en`. - string language_code = 5; -} - -// Configures Merchant Center linking. -// Links contained in the config will be used to sync data from a Merchant -// Center account to a Cloud Retail branch. -message MerchantCenterLinkingConfig { - // Links between Merchant Center accounts and branches. - repeated MerchantCenterLink links = 1; -} - -// The catalog configuration. -message Catalog { - option (google.api.resource) = { - type: "retail.googleapis.com/Catalog" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" - }; - - // Required. Immutable. The fully qualified resource name of the catalog. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. Immutable. The catalog display name. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. The product level configuration. - ProductLevelConfig product_level_config = 4 - [(google.api.field_behavior) = REQUIRED]; - - // The Merchant Center linking configuration. - // Once a link is added, the data stream from Merchant Center to Cloud Retail - // will be enabled automatically. The requester must have access to the - // merchant center account in order to make changes to this field. - MerchantCenterLinkingConfig merchant_center_linking_config = 6; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto deleted file mode 100644 index 6ecab725..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto +++ /dev/null @@ -1,478 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/catalog.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for managing catalog configuration. -service CatalogService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated - // with the project. - rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*}/catalogs" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s. - rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { - option (google.api.http) = { - patch: "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}" - body: "catalog" - }; - option (google.api.method_signature) = "catalog,update_mask"; - } - - // Set a specified branch id as default branch. API methods such as - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] - // will treat requests using "default_branch" to the actual branch id set as - // default. - // - // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as - // default, setting - // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent - // to setting - // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/1`. - // - // Using multiple branches can be useful when developers would like - // to have a staging branch to test and verify for future usage. When it - // becomes ready, developers switch on the staging branch using this API while - // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` - // as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] - // to route the traffic to this staging branch. - // - // CAUTION: If you have live predict/search traffic, switching the default - // branch could potentially cause outages if the ID space of the new branch is - // very different from the old one. - // - // More specifically: - // - // * PredictionService will only return product IDs from branch {newBranch}. - // * SearchService will only return product IDs from branch {newBranch} - // (if branch is not explicitly set). - // * UserEventService will only join events with products from branch - // {newBranch}. - rpc SetDefaultBranch(SetDefaultBranchRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" - body: "*" - }; - option (google.api.method_signature) = "catalog"; - } - - // Get which branch is currently default branch set by - // [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] - // method under a specified parent catalog. - rpc GetDefaultBranch(GetDefaultBranchRequest) - returns (GetDefaultBranchResponse) { - option (google.api.http) = { - get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" - }; - option (google.api.method_signature) = "catalog"; - } - - // Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]. - rpc GetCompletionConfig(GetCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/completionConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the - // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s. - rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - patch: "/v2alpha/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" - body: "completion_config" - }; - option (google.api.method_signature) = "completion_config,update_mask"; - } - - // Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. - rpc GetAttributesConfig(GetAttributesConfigRequest) - returns (AttributesConfig) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/attributesConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. - // - // The catalog attributes in the request will be updated in the catalog, or - // inserted if they do not exist. Existing catalog attributes not included in - // the request will remain unchanged. Attributes that are assigned to - // products, but do not exist at the catalog level, are always included in the - // response. The product attribute is assigned default values for missing - // catalog attribute fields, e.g., searchable and dynamic facetable options. - rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) - returns (AttributesConfig) { - option (google.api.http) = { - patch: "/v2alpha/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" - body: "attributes_config" - }; - option (google.api.method_signature) = "attributes_config,update_mask"; - } - - // Adds the specified - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to - // add already exists, an ALREADY_EXISTS error is returned. - rpc AddCatalogAttribute(AddCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" - body: "*" - }; - } - - // Removes the specified - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to - // remove does not exist, a NOT_FOUND error is returned. - rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" - body: "*" - }; - } - - // Replaces the specified - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by - // updating the catalog attribute with the same - // [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. - // - // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to - // replace does not exist, a NOT_FOUND error is returned. - rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" - body: "*" - }; - } -} - -// Request for -// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] -// method. -message ListCatalogsRequest { - // Required. The account resource name with an associated location. - // - // If the caller does not have permission to list - // [Catalog][google.cloud.retail.v2alpha.Catalog]s under this location, - // regardless of whether or not this location exists, a PERMISSION_DENIED - // error is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of [Catalog][google.cloud.retail.v2alpha.Catalog]s to - // return. If unspecified, defaults to 50. The maximum allowed value is 1000. - // Values above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 2; - - // A page token - // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token], - // received from a previous - // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; -} - -// Response for -// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] -// method. -message ListCatalogsResponse { - // All the customer's [Catalog][google.cloud.retail.v2alpha.Catalog]s. - repeated Catalog catalogs = 1; - - // A token that can be sent as - // [ListCatalogsRequest.page_token][google.cloud.retail.v2alpha.ListCatalogsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request for -// [CatalogService.UpdateCatalog][google.cloud.retail.v2alpha.CatalogService.UpdateCatalog] -// method. -message UpdateCatalogRequest { - // Required. The [Catalog][google.cloud.retail.v2alpha.Catalog] to update. - // - // If the caller does not have permission to update the - // [Catalog][google.cloud.retail.v2alpha.Catalog], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Catalog][google.cloud.retail.v2alpha.Catalog] to update does not - // exist, a NOT_FOUND error is returned. - Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Catalog][google.cloud.retail.v2alpha.Catalog] to update. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message to set a specified branch as new default_branch. -message SetDefaultBranchRequest { - // Full resource name of the catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // The final component of the resource name of a branch. - // - // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - // error is returned. - // - // If there are no sufficient active products in the targeted branch and - // [force][google.cloud.retail.v2alpha.SetDefaultBranchRequest.force] is not - // set, a FAILED_PRECONDITION error is returned. - string branch_id = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Some note on this request, this can be retrieved by - // [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch] - // before next valid default branch set occurs. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string note = 3; - - // If set to true, it permits switching to a branch with - // [branch_id][google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id] - // even if it has no sufficient active products. - bool force = 4; -} - -// Request message to show which branch is currently the default branch. -message GetDefaultBranchRequest { - // The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; -} - -// Response message of -// [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch]. -message GetDefaultBranchResponse { - // Full resource name of the branch id currently set as default branch. - string branch = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // The time when this branch is set to default. - google.protobuf.Timestamp set_time = 2; - - // This corresponds to - // [SetDefaultBranchRequest.note][google.cloud.retail.v2alpha.SetDefaultBranchRequest.note] - // field, when this branch was set as default. - string note = 3; -} - -// Request for -// [CatalogService.GetCompletionConfig][google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig] -// method. -message GetCompletionConfigRequest { - // Required. Full CompletionConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/CompletionConfig" - } - ]; -} - -// Request for -// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig] -// method. -message UpdateCompletionConfigRequest { - // Required. The - // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. - // - // If the caller does not have permission to update the - // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig], then a - // PERMISSION_DENIED error is returned. - // - // If the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to - // update does not exist, a NOT_FOUND error is returned. - CompletionConfig completion_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. - // The following are the only supported fields: - // - // * [CompletionConfig.matching_order][google.cloud.retail.v2alpha.CompletionConfig.matching_order] - // * [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions] - // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length] - // * [CompletionConfig.auto_learning][google.cloud.retail.v2alpha.CompletionConfig.auto_learning] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.GetAttributesConfig][google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig] -// method. -message GetAttributesConfigRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; -} - -// Request for -// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig] -// method. -message UpdateAttributesConfigRequest { - // Required. The - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. - AttributesConfig attributes_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. - // The following is the only supported field: - // - // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute] -// method. -message AddCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute] -// method. -message RemoveCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The attribute name key of the - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove. - string key = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute] -// method. -message ReplaceCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The updated - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to update. - // The following are NOT supported: - // - // * [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 3; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto deleted file mode 100644 index ae33d3f6..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/common.proto +++ /dev/null @@ -1,761 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// At which level we offer configuration for attributes. -enum AttributeConfigLevel { - // Value used when unset. Defaults to - // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2alpha.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. - ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; - - // At this level, we honor the attribute configurations set in - // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. - PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; - - // At this level, we honor the attribute configurations set in - // [CatalogConfig.attribute_configs][google.cloud.retail.v2alpha.CatalogConfig.attribute_configs]. - CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; -} - -// The type of solution. -enum SolutionType { - // Default value. - SOLUTION_TYPE_UNSPECIFIED = 0; - - // Used for Recommendations AI. - SOLUTION_TYPE_RECOMMENDATION = 1; - - // Used for Retail Search. - SOLUTION_TYPE_SEARCH = 2; -} - -// The use case of Cloud Retail Search. -enum SearchSolutionUseCase { - // The value when it's unspecified. Defaults to - // [SEARCH][]. - SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; - - // Search use case. Expects the traffic has a non-empty - // [query][google.cloud.retail.v2alpha.SearchRequest.query]. - SEARCH_SOLUTION_USE_CASE_SEARCH = 1; - - // Browse use case. Expects the traffic has an empty - // [query][google.cloud.retail.v2alpha.SearchRequest.query]. - SEARCH_SOLUTION_USE_CASE_BROWSE = 2; -} - -// Metadata that is used to define a condition that triggers an action. -// A valid condition must specify at least one of 'query_terms' or -// 'products_filter'. If multiple fields are specified, the condition is met if -// all the fields are satisfied e.g. if a set of query terms and product_filter -// are set, then only items matching the product_filter for requests with a -// query matching the query terms wil get boosted. -message Condition { - // Query terms that we want to match on. - message QueryTerm { - // The value of the term to match on. - // Value cannot be empty. - // Value can have at most 3 terms if specified as a partial match. Each - // space separated string is considered as one term. - // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not - // allowed for partial match. - string value = 1; - - // Whether this is supposed to be a full or partial match. - bool full_match = 2; - } - - // Used for time-dependent conditions. - // Example: Want to have rule applied for week long sale. - message TimeRange { - // Start of time range. Range is inclusive. - google.protobuf.Timestamp start_time = 1; - - // End of time range. Range is inclusive. - google.protobuf.Timestamp end_time = 2; - } - - // A list (up to 10 entries) of terms to match the query on. If not - // specified, match all queries. - // If many query terms are specified, the condition - // is matched if any of the terms is a match (i.e. using the OR operator). - repeated QueryTerm query_terms = 1; - - // Range of time(s) specifying when Condition is active. - // Condition true if any time range matches. - repeated TimeRange active_time_range = 3; -} - -// A rule is a condition-action pair -// * A condition defines when a rule is to be triggered. -// * An action specifies what occurs on that trigger. -// Currently only boost rules are supported. -// Currently only supported by the search endpoint. -message Rule { - // A boost action to apply to results matching condition specified above. - message BoostAction { - // Strength of the condition boost, which must be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 1; - - // The filter can have a max size of 5000 characters. - // An expression which specifies which products to apply an action to. - // The syntax and supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue":
- // *(id: ANY("product_1", "product_2"))
* - // *AND
* - // *(colorFamilies: ANY("Red", "Blue"))
* - string products_filter = 2; - } - - // * Rule Condition: - // - No [Condition][query_terms] provided is a global match. - // - 1 or more [Condition][query_terms] provided is combined with OR - // operator. - // * Action Input: The request query and filter that will be applied to the - // retrieved products, in addition to any filters already provided with the - // SearchRequest. The AND operator is used to combine the query's existing - // filters with the filter rule(s). NOTE: May result in 0 results when - // filters conflict. - // * Action Result: Filters the returned objects to be ONLY those that passed - // the filter. - message FilterAction { - // A filter to apply on the matching condition results. Supported features: - // - // * [filter][google.cloud.retail.v2alpha.Rule.FilterAction.filter] must be - // set. - // * Filter syntax is identical to - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]. - // See more - // details at the Retail Search - // [user guide](/retail/search/docs/filter-and-order#filter). - // * To filter products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue":
- // *(id: ANY("product_1", "product_2"))
* - // *AND
* - // *(colorFamilies: ANY("Red", "Blue"))
* - string filter = 1; - } - - // Redirects a shopper to a specific page. - // * Rule Condition: - // - Must specify [Condition][query_terms]. - // * Action Input: Request Query - // * Action Result: Redirects shopper to provided uri. - message RedirectAction { - // URL must have length equal or less than 2000 characters. - string redirect_uri = 1; - } - - // Creates a set of terms that will be treated as synonyms of each other. - // Example: synonyms of "sneakers" and "shoes". - // * "sneakers" will use a synonym of "shoes". - // * "shoes" will use a synonym of "sneakers". - message TwowaySynonymsAction { - // Defines a set of synonyms. - // Can specify up to 100 synonyms. - // Must specify at least 2 synonyms. - repeated string synonyms = 1; - } - - // Maps a set of terms to a set of synonyms. - // Set of synonyms will be treated as synonyms of each query term only. - // `query_terms` will not be treated as synonyms of each other. - // Example: "sneakers" will use a synonym of "shoes". - // "shoes" will not use a synonym of "sneakers". - message OnewaySynonymsAction { - // Terms from the search query. - // Will treat synonyms as their synonyms. - // Not themselves synonyms of the synonyms. - // Can specify up to 100 terms. - repeated string query_terms = 3; - - // Defines a set of synonyms. - // Cannot contain duplicates. - // Can specify up to 100 synonyms. - repeated string synonyms = 4; - - // Will be [deprecated = true] post migration; - repeated string oneway_terms = 2; - } - - // Prevents `query_term` from being associated with specified terms during - // search. - // Example: Don't associate "gShoe" and "cheap". - message DoNotAssociateAction { - // Terms from the search query. - // Will not consider do_not_associate_terms for search if in search query. - // Can specify up to 100 terms. - repeated string query_terms = 2; - - // Cannot contain duplicates or the query term. - // Can specify up to 100 terms. - repeated string do_not_associate_terms = 3; - - // Will be [deprecated = true] post migration; - repeated string terms = 1; - } - - // Replaces a term in the query. Multiple replacement candidates can be - // specified. All `query_terms` will be replaced with the replacement term. - // Example: Replace "gShoe" with "google shoe". - message ReplacementAction { - // Terms from the search query. - // Will be replaced by replacement term. - // Can specify up to 100 terms. - repeated string query_terms = 2; - - // Term that will be used for replacement. - string replacement_term = 3; - - // Will be [deprecated = true] post migration; - string term = 1; - } - - // Prevents a term in the query from being used in search. - // Example: Don't search for "shoddy". - message IgnoreAction { - // Terms to ignore in the search query. - repeated string ignore_terms = 1; - } - - // An action must be provided. - oneof action { - // A boost action. - BoostAction boost_action = 2; - - // Redirects a shopper to a specific page. - RedirectAction redirect_action = 3; - - // Treats specific term as a synonym with a group of terms. - // Group of terms will not be treated as synonyms with the specific term. - OnewaySynonymsAction oneway_synonyms_action = 6; - - // Prevents term from being associated with other terms. - DoNotAssociateAction do_not_associate_action = 7; - - // Replaces specific terms in the query. - ReplacementAction replacement_action = 8; - - // Ignores specific terms from query during search. - IgnoreAction ignore_action = 9; - - // Filters results. - FilterAction filter_action = 10; - - // Treats a set of terms as synonyms of one another. - TwowaySynonymsAction twoway_synonyms_action = 11; - } - - // Required. The condition that triggers the rule. - // If the condition is empty, the rule will always apply. - Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// An intended audience of the [Product][google.cloud.retail.v2alpha.Product] -// for whom it's sold. -message Audience { - // The genders of the audience. Strongly encouraged to use the standard - // values: "male", "female", "unisex". - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [gender](https://support.google.com/merchants/answer/6324479). Schema.org - // property - // [Product.audience.suggestedGender](https://schema.org/suggestedGender). - repeated string genders = 1; - - // The age groups of the audience. Strongly encouraged to use the standard - // values: "newborn" (up to 3 months old), "infant" (3–12 months old), - // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically - // teens or older). - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [age_group](https://support.google.com/merchants/answer/6324463). - // Schema.org property - // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and - // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). - repeated string age_groups = 2; -} - -// The color information of a [Product][google.cloud.retail.v2alpha.Product]. -message ColorInfo { - // The standard color families. Strongly recommended to use the following - // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", - // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and - // "Mixed". Normally it is expected to have only 1 color family. May consider - // using single "Mixed" instead of multiple values. - // - // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string color_families = 1; - - // The color display names, which may be different from standard color family - // names, such as the color aliases used in the website frontend. Normally - // it is expected to have only 1 color. May consider using single "Mixed" - // instead of multiple values. - // - // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string colors = 2; -} - -// A custom attribute that is not explicitly modeled in -// [Product][google.cloud.retail.v2alpha.Product]. -message CustomAttribute { - // The textual values of this custom attribute. For example, `["yellow", - // "green"]` when the key is "color". - // - // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be - // set. Otherwise, an INVALID_ARGUMENT error is returned. - repeated string text = 1; - - // The numerical values of this custom attribute. For example, `[2.3, 15.4]` - // when the key is "lengths_cm". - // - // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be - // set. Otherwise, an INVALID_ARGUMENT error is returned. - repeated double numbers = 2; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // This field is ignored in a - // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. - // - // Only set if type [text][google.cloud.retail.v2alpha.CustomAttribute.text] - // is set. Otherwise, a INVALID_ARGUMENT error is returned. - optional bool searchable = 3; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // indexed, so that it can be filtered, faceted or boosted in - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // This field is ignored in a - // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. - // - // See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter], - // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] - // and - // [SearchRequest.boost_spec][google.cloud.retail.v2alpha.SearchRequest.boost_spec] - // for more details. - optional bool indexable = 4; -} - -// Fulfillment information, such as the store IDs for in-store pickup or region -// IDs for different shipping methods. -message FulfillmentInfo { - // The fulfillment type, including commonly used types (such as pickup in - // store and same day delivery), and custom types. Customers have to map - // custom types to their display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - string type = 1; - - // The IDs for this [type][google.cloud.retail.v2alpha.FulfillmentInfo.type], - // such as the store IDs for - // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // or the region IDs for - // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2alpha.FulfillmentInfo.type]. - // - // A maximum of 3000 values are allowed. Each value must be a string with a - // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such - // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string place_ids = 2; -} - -// [Product][google.cloud.retail.v2alpha.Product] image. Recommendations AI and -// Retail Search do not use product images to improve prediction and search -// results. However, product images can be returned in results, and are shown in -// prediction or search previews in the console. -message Image { - // Required. URI of the image. - // - // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // Height of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 height = 2; - - // Width of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 width = 3; -} - -// A floating point interval. -message Interval { - // The lower bound of the interval. If neither of the min fields are set, then - // the lower bound is negative infinity. - // - // This field must be not larger than - // [max][google.cloud.retail.v2alpha.Interval.max]. Otherwise, an - // INVALID_ARGUMENT error is returned. - oneof min { - // Inclusive lower bound. - double minimum = 1; - - // Exclusive lower bound. - double exclusive_minimum = 2; - } - - // The upper bound of the interval. If neither of the max fields are set, then - // the upper bound is positive infinity. - // - // This field must be not smaller than - // [min][google.cloud.retail.v2alpha.Interval.min]. Otherwise, an - // INVALID_ARGUMENT error is returned. - oneof max { - // Inclusive upper bound. - double maximum = 3; - - // Exclusive upper bound. - double exclusive_maximum = 4; - } -} - -// The price information of a [Product][google.cloud.retail.v2alpha.Product]. -message PriceInfo { - // The price range of all - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. - message PriceRange { - // The inclusive - // [Product.pricing_info.price][google.cloud.retail.v2alpha.PriceInfo.price] - // interval of all - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. - Interval price = 1; - - // The inclusive - // [Product.pricing_info.original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] - // internal of all - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. - Interval original_price = 2; - } - - // The 3-letter currency code defined in [ISO - // 4217](https://www.iso.org/iso-4217-currency-codes.html). - // - // If this field is an unrecognizable currency code, an INVALID_ARGUMENT - // error is returned. - // - // The - // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s with the same - // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] - // must share the same - // [currency_code][google.cloud.retail.v2alpha.PriceInfo.currency_code]. - // Otherwise, a FAILED_PRECONDITION error is returned. - string currency_code = 1; - - // Price of the product. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). Schema.org - // property [Offer.price](https://schema.org/price). - float price = 2; - - // Price of the product without any discount. If zero, by default set to be - // the [price][google.cloud.retail.v2alpha.PriceInfo.price]. - float original_price = 3; - - // The costs associated with the sale of a particular product. Used for gross - // profit reporting. - // - // * Profit = [price][google.cloud.retail.v2alpha.PriceInfo.price] - - // [cost][google.cloud.retail.v2alpha.PriceInfo.cost] - // - // Google Merchant Center property - // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). - float cost = 4; - - // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] - // starts to be effective. This can be set as a future timestamp, and the - // [price][google.cloud.retail.v2alpha.PriceInfo.price] is only used for - // search after - // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. - // If so, the - // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must - // be set and - // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is - // used before - // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. - // - // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is - // always effective because it will cause additional latency during search. - google.protobuf.Timestamp price_effective_time = 5; - - // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] - // stops to be effective. The - // [price][google.cloud.retail.v2alpha.PriceInfo.price] is used for search - // before - // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. - // If this field is set, the - // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must - // be set and - // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is - // used after - // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. - // - // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is - // always effective because it will cause additional latency during search. - google.protobuf.Timestamp price_expire_time = 6; - - // Output only. The price range of all the child - // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s grouped together on the - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]. Only populated for - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. - // Do not set this field in API requests. - PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The rating of a [Product][google.cloud.retail.v2alpha.Product]. -message Rating { - // The total number of ratings. This value is independent of the value of - // [rating_histogram][google.cloud.retail.v2alpha.Rating.rating_histogram]. - // - // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 rating_count = 1; - - // The average rating of the [Product][google.cloud.retail.v2alpha.Product]. - // - // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is - // returned. - float average_rating = 2; - - // List of rating counts per rating value (index = rating - 1). The list is - // empty if there is no rating. If the list is non-empty, its size is - // always 5. Otherwise, an INVALID_ARGUMENT error is returned. - // - // For example, [41, 14, 13, 47, 303]. It means that the - // [Product][google.cloud.retail.v2alpha.Product] got 41 ratings with 1 star, - // 14 ratings with 2 star, and so on. - repeated int32 rating_histogram = 3; -} - -// Information of an end user. -message UserInfo { - // Highly recommended for logged-in users. Unique identifier for logged-in - // user, such as a user name. - // - // Always use a hashed value for this ID. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string user_id = 1; - - // The end user's IP address. This field is used to extract location - // information for personalization. - // - // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 - // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This should not be set when: - // - // * setting - // [SearchRequest.user_info][google.cloud.retail.v2alpha.SearchRequest.user_info]. - // * using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] - // is set. - string ip_address = 2; - - // User agent as included in the HTTP header. Required for getting - // [SearchResponse.sponsored_results][google.cloud.retail.v2alpha.SearchResponse.sponsored_results]. - // - // The field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This should not be set when using the client side event reporting with - // GTM or JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] - // is set. - string user_agent = 3; - - // True if the request is made directly from the end user, in which case the - // [ip_address][google.cloud.retail.v2alpha.UserInfo.ip_address] and - // [user_agent][google.cloud.retail.v2alpha.UserInfo.user_agent] can be - // populated from the HTTP request. This flag should be set only if the API - // request is made directly from the end user such as a mobile app (and not if - // a gateway or a server is processing and pushing the user events). - // - // This should not be set when using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent]. - bool direct_user_request = 4; -} - -// The inventory information at a place (e.g. a store) identified -// by a place ID. -message LocalInventory { - // The place ID for the current set of inventory information. - string place_id = 1; - - // Product price and cost information. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 2; - - // Additional local inventory attributes, for example, store name, promotion - // tags, etc. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * At most 30 attributes are allowed. - // * The key must be a UTF-8 encoded string with a length limit of 32 - // characters. - // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, - // key0LikeThis or KEY_1_LIKE_THIS. - // * The attribute values must be of the same type (text or number). - // * Only 1 value is allowed for each attribute. - // * For text values, the length limit is 256 UTF-8 characters. - // * The attribute does not support search. The `searchable` field should be - // unset or set to false. - // * The max summed total bytes of custom attribute keys and values per - // product is 5MiB. - map attributes = 3; - - // Input only. Supported fulfillment types. Valid fulfillment type values - // include commonly used types (such as pickup in store and same day - // delivery), and custom types. Customers have to map custom types to their - // display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string fulfillment_types = 4 - [(google.api.field_behavior) = INPUT_ONLY]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto deleted file mode 100644 index a91aa618..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/import_config.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "CompletionServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Auto-completion service for retail. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service CompletionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Completes the specified prefix with keyword suggestions. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { - option (google.api.http) = { - get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" - }; - } - - // Bulk import of processed completion dataset. - // - // Request processing is asynchronous. Partial updating is not supported. - // - // The operation is successfully finished only after the imported suggestions - // are indexed successfully and ready for serving. The process takes hours. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc ImportCompletionData(ImportCompletionDataRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/completionData:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.ImportCompletionDataResponse" - metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" - }; - } -} - -// Auto-complete parameters. -message CompleteQueryRequest { - // Required. Catalog for which the completion is performed. - // - // Full resource name of catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The query used to generate suggestions. - // - // The maximum number of allowed characters is 255. - string query = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required field. A unique identifier for tracking visitors. For example, - // this could be implemented with an HTTP cookie, which should be able to - // uniquely identify a visitor on a single device. This unique identifier - // should not change if the visitor logs in or out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 7; - - // The language filters applied to the output suggestions. If set, it should - // contain the language of the query. If not set, suggestions are returned - // without considering language restrictions. This is the BCP-47 language - // code, such as "en-US" or "sr-Latn". For more information, see [Tags for - // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - // number of language codes is 3. - repeated string language_codes = 3; - - // The device type context for completion suggestions. - // It is useful to apply different suggestions on different device types, e.g. - // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - // types. - // - // Supported formats: - // - // * `UNKNOWN_DEVICE_TYPE` - // - // * `DESKTOP` - // - // * `MOBILE` - // - // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - string device_type = 4; - - // Determines which dataset to use for fetching completion. "user-data" will - // use the imported dataset through - // [CompletionService.ImportCompletionData][google.cloud.retail.v2alpha.CompletionService.ImportCompletionData]. - // "cloud-retail" will use the dataset generated by cloud retail based on user - // events. If leave empty, it will use the "user-data". - // - // Current supported values: - // - // * user-data - // - // * cloud-retail - // This option requires additional allowlisting. Before using cloud-retail, - // contact Cloud Retail support team first. - string dataset = 6; - - // Completion max suggestions. If left unset or set to 0, then will fallback - // to the configured value - // [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions]. - // - // The maximum allowed max suggestions is 20. If it is set higher, it will be - // capped by 20. - int32 max_suggestions = 5; -} - -// Response of the auto-complete query. -message CompleteQueryResponse { - // Resource that represents completion results. - message CompletionResult { - // The suggestion for the query. - string suggestion = 1; - - // Custom attributes for the suggestion term. - // * For "user-data", the attributes are additional custom attributes - // ingested through BigQuery. - // * For "cloud-retail", the attributes are product attributes generated - // by Cloud Retail. - map attributes = 2; - } - - // Recent search of this user. - message RecentSearchResult { - // The recent search query. - string recent_search = 1; - } - - // Results of the matching suggestions. The result list is ordered and the - // first result is top suggestion. - repeated CompletionResult completion_results = 1; - - // A unique complete token. This should be included in the - // [UserEvent.completion_detail][google.cloud.retail.v2alpha.UserEvent.completion_detail] - // for search events resulting from this completion, which enables accurate - // attribution of complete model performance. - string attribution_token = 2; - - // Matched recent searches of this user. The maximum number of recent searches - // is 10. This field is a restricted feature. Contact Retail Search support - // team if you are interested in enabling it. - // - // This feature is only available when - // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2alpha.CompleteQueryRequest.visitor_id] - // field is set and [UserEvent][google.cloud.retail.v2alpha.UserEvent] is - // imported. The recent searches satisfy the follow rules: - // * They are ordered from latest to oldest. - // * They are matched with - // [CompleteQueryRequest.query][google.cloud.retail.v2alpha.CompleteQueryRequest.query] - // case insensitively. - // * They are transformed to lower cases. - // * They are UTF-8 safe. - // - // Recent searches are deduplicated. More recent searches will be reserved - // when duplication happens. - repeated RecentSearchResult recent_search_results = 3; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto deleted file mode 100644 index 4d85015e..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control.proto +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/search_service.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ControlProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Configures dynamic serving time metadata that is used to pre and post -// process search/recommendation model results. -message Control { - option (google.api.resource) = { - type: "retail.googleapis.com/Control" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" - }; - - // The behavior/type of the control - // - // A behavior/type must be specified on creation. Type cannot be changed once - // specified (e.g. A Rule control will always be a Rule control.). An - // INVALID_ARGUMENT will be returned if either condition is violated. - oneof control { - // A facet specification to perform faceted search. - SearchRequest.FacetSpec facet_spec = 3; - - // A rule control - a condition-action pair. - // Enacts a set action when the condition is triggered. - // For example: Boost "gShoe" when query full matches "Running Shoes". - Rule rule = 4; - } - - // Immutable. Fully qualified name - // projects/*/locations/global/catalogs/*/controls/* - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. The human readable control display name. Used in Retail UI. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is thrown. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Output only. List of serving configuration ids that that are associated - // with this control. Note the association is managed via the ServingConfig, - // this is an output only denormalizeed view. Assumed to be in the same - // catalog. - repeated string associated_serving_config_ids = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Immutable. The solution types that the serving config is used - // for. Currently we support setting only one type of solution at creation - // time. - // - // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. - // If no solution type is provided at creation time, will default to - // SOLUTION_TYPE_SEARCH. - repeated SolutionType solution_types = 6 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. Specifies the use case for the control. - // Affects what condition fields can be set. - // Only settable by search controls. - // Will default to SEARCH_SOLUTION_USE_CASE_SEARCH if not specified. - // Currently only allow one search_solution_use_case per control. - repeated SearchSolutionUseCase search_solution_use_case = 7 - [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto deleted file mode 100644 index 6372aca6..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/control.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ControlServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for modifying Control. -service ControlService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a Control. - // - // If the [Control][google.cloud.retail.v2alpha.Control] to create already - // exists, an ALREADY_EXISTS error is returned. - rpc CreateControl(CreateControlRequest) returns (Control) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" - body: "control" - }; - option (google.api.method_signature) = "parent,control,control_id"; - } - - // Deletes a Control. - // - // If the [Control][google.cloud.retail.v2alpha.Control] to delete does not - // exist, a NOT_FOUND error is returned. - rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a Control. - // - // [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different - // oneof field, if so an INVALID_ARGUMENT is returned. If the - // [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a - // NOT_FOUND error is returned. - rpc UpdateControl(UpdateControlRequest) returns (Control) { - option (google.api.http) = { - patch: "/v2alpha/{control.name=projects/*/locations/*/catalogs/*/controls/*}" - body: "control" - }; - option (google.api.method_signature) = "control,update_mask"; - } - - // Gets a Control. - rpc GetControl(GetControlRequest) returns (Control) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all Controls linked to this catalog. - rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Request for CreateControl method. -message CreateControlRequest { - // Required. Full resource name of parent catalog. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The Control to create. - Control control = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the Control, which will become the final - // component of the Control's resource name. - // - // This value should be 4-63 characters, and valid characters - // are /[a-z][0-9]-_/. - string control_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for UpdateControl method. -message UpdateControlRequest { - // Required. The Control to update. - Control control = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Control][google.cloud.retail.v2alpha.Control] to update. The following are - // NOT supported: - // - // * [Control.name][google.cloud.retail.v2alpha.Control.name] - // - // If not set or empty, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for DeleteControl method. -message DeleteControlRequest { - // Required. The resource name of the Control to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } - ]; -} - -// Request for GetControl method. -message GetControlRequest { - // Required. The resource name of the Control to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } - ]; -} - -// Request for ListControls method. -message ListControlsRequest { - // Required. The catalog resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Optional. Maximum number of results to return. If unspecified, defaults - // to 50. Max allowed value is 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListControls` call. - // Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2alpha.ListControlsRequest.filter] is unset. - // * List controls that are used in a single ServingConfig: - // 'serving_config = "boosted_home_page_cvr"' - string filter = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for ListControls method. -message ListControlsResponse { - // All the Controls for a given catalog. - repeated Control controls = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto deleted file mode 100644 index f29c7f9a..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ExportConfigProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Configuration of destination for Export related errors. -message ExportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage path for import errors. This must be an empty, - // existing Cloud Storage bucket. Export errors will be written to a file in - // this bucket, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Metadata related to the progress of the Export operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ExportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} - -// Response of the ExportProductsRequest. If the long running -// operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ExportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ExportErrorsConfig errors_config = 2; -} - -// Response of the ExportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ExportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ExportErrorsConfig errors_config = 2; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto deleted file mode 100644 index a1fcf240..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/product.proto"; -import "google/cloud/retail/v2alpha/user_event.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ImportConfigProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Google Cloud Storage location for input content. -// format. -message GcsSource { - // Required. Google Cloud Storage URIs to input files. URI can be up to - // 2000 characters long. URIs can match the full object path (for example, - // `gs://bucket/directory/object.json`) or a pattern matching one or more - // files, such as `gs://bucket/directory/*.json`. A request can - // contain at most 100 files, and each file can be up to 2 GB. See - // [Importing product - // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) - // for the expected file format and setup instructions. - repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON - // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. - // * `user_event_ga360`: Using - // https://support.google.com/analytics/answer/3437719. - // - // Supported values for control imports: - // - // * 'control' (default): One JSON - // [Control][google.cloud.retail.v2alpha.Control] per line. - // - // Supported values for catalog attribute imports: - // - // * 'catalog_attribute' (default): One CSV - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] per line. - string data_schema = 2; -} - -// BigQuery source import data from. -message BigQuerySource { - // BigQuery table partition info. Leave this empty if the BigQuery table - // is not partitioned. - oneof partition { - // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - google.type.Date partition_date = 6; - } - - // The project ID (can be project # or ID) that the BigQuery source is in with - // a length limit of 128 characters. If not specified, inherits the project - // ID from the parent request. - string project_id = 5; - - // Required. The BigQuery data set to copy the data from with a length limit - // of 1,024 characters. - string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The BigQuery table to copy the data from with a length limit of - // 1,024 characters. - string table_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Intermediate Cloud Storage directory used for the import with a length - // limit of 2,000 characters. Can be specified if one wants to have the - // BigQuery export to a specific Cloud Storage directory. - string gcs_staging_dir = 3; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON - // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. - // * `user_event_ga360`: - // The schema is available here: - // https://support.google.com/analytics/answer/3437719. - // * `user_event_ga4`: This feature is in private preview. Please contact the - // support team for importing Google Analytics 4 events. - // The schema is available here: - // https://support.google.com/analytics/answer/7029846. - // - // Supported values for auto-completion imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - string data_schema = 4; -} - -// The inline source for the input config for ImportProducts method. -message ProductInlineSource { - // Required. A list of products to update/create. Each product must have a - // valid [Product.id][google.cloud.retail.v2alpha.Product.id]. Recommended max - // of 100 items. - repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The inline source for the input config for ImportUserEvents method. -message UserEventInlineSource { - // Required. A list of user events to import. Recommended max of 10k items. - repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Configuration of destination for Import related errors. -message ImportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage prefix for import errors. This must be an empty, - // existing Cloud Storage directory. Import errors will be written to - // sharded files in this directory, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Request message for Import methods. -message ImportProductsRequest { - // Indicates how imported products are reconciled with the existing products - // created or imported before. - enum ReconciliationMode { - // Defaults to INCREMENTAL. - RECONCILIATION_MODE_UNSPECIFIED = 0; - - // Inserts new products or updates existing products. - INCREMENTAL = 1; - - // Calculates diff and replaces the entire product dataset. Existing - // products may be deleted if they are not present in the source location. - // - // Can only be set while using - // [BigQuerySource][google.cloud.retail.v2alpha.BigQuerySource]. And the - // BigQuery dataset must be created in the data location "us (multiple - // regions in United States)", otherwise a PERMISSION_DENIED error is - // thrown. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - FULL = 2; - } - - // Required. - // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - // - // If no updateMask is specified, requires products.create permission. - // If updateMask is specified, requires products.update permission. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Deprecated. This field has no effect. - string request_id = 6 [deprecated = true]; - - // Required. The desired input location of the data. - ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. - ImportErrorsConfig errors_config = 3; - - // Indicates which fields in the provided imported 'products' to update. If - // not set, will by default update all fields. - google.protobuf.FieldMask update_mask = 4; - - // The mode of reconciliation between existing products and the products to be - // imported. Defaults to - // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. - ReconciliationMode reconciliation_mode = 5; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - string notification_pubsub_topic = 7; -} - -// Request message for the ImportUserEvents request. -message ImportUserEventsRequest { - // Required. `projects/1234/locations/global/catalogs/default_catalog` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - UserEventInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. Cannot be set - // for inline user event imports. - ImportErrorsConfig errors_config = 3; -} - -// Request message for ImportCompletionData methods. -message ImportCompletionDataRequest { - // Required. The catalog which the suggestions dataset belongs to. - // - // Format: `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - CompletionDataInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 3; -} - -// The input config source for products. -message ProductInputConfig { - // Required. The source of the input. - oneof source { - // The Inline source for the input content for products. - ProductInlineSource product_inline_source = 1; - - // Google Cloud Storage location for the input content. - GcsSource gcs_source = 2; - - // BigQuery input source. - BigQuerySource big_query_source = 3; - } -} - -// The input config source for user events. -message UserEventInputConfig { - // The source of the input. - oneof source { - // Required. The Inline source for the input content for UserEvents. - UserEventInlineSource user_event_inline_source = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Google Cloud Storage location for the input content. - GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. BigQuery input source. - BigQuerySource big_query_source = 3 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// The input config source for completion data. -message CompletionDataInputConfig { - // The source of the input. - // - // Supported - // [BigQuerySource.data_schema][google.cloud.retail.v2alpha.BigQuerySource.data_schema] - // values for suggestions imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - oneof source { - // Required. BigQuery input source. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - BigQuerySource big_query_source = 1 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// Metadata related to the progress of the Import operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ImportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; - - // Deprecated. This field is never set. - string request_id = 5 [deprecated = true]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 6; -} - -// Response of the -// [ImportProductsRequest][google.cloud.retail.v2alpha.ImportProductsRequest]. -// If the long running operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ImportErrorsConfig errors_config = 2; -} - -// Response of the ImportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ImportErrorsConfig errors_config = 2; - - // Aggregated statistics of user event import status. - UserEventImportSummary import_summary = 3; -} - -// A summary of import result. The UserEventImportSummary summarizes -// the import status for user events. -message UserEventImportSummary { - // Count of user events imported with complete existing catalog information. - int64 joined_events_count = 1; - - // Count of user events imported, but with catalog information not found - // in the imported catalog. - int64 unjoined_events_count = 2; -} - -// Response of the -// [ImportCompletionDataRequest][google.cloud.retail.v2alpha.ImportCompletionDataRequest]. -// If the long running operation is done, this message is returned by the -// google.longrunning.Operations.response field if the operation is successful. -message ImportCompletionDataResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto deleted file mode 100644 index 5b89bceb..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2alpha/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "PredictionServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for making recommendation prediction. -service PredictionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Makes a recommendation prediction. - rpc Predict(PredictRequest) returns (PredictResponse) { - option (google.api.http) = { - post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" - body: "*" - }; - } -} - -// Request message for Predict method. -message PredictRequest { - // Required. Full resource name of the format: - // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} - // The ID of the Recommendations AI placement. Before you can request - // predictions from your model, you must create at least one placement for it. - // For more information, see [Managing - // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - // - // The full list of available placements can be seen at - // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Context about the user, what they are looking at and what action - // they took to trigger the predict request. Note that this user event detail - // won't be ingested to userEvent logs. Thus, a separate userEvent write - // request is required for event logging. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // Maximum number of results to return per page. Set this property - // to the number of prediction results needed. If zero, the service will - // choose a reasonable default. The maximum allowed value is 100. Values - // above 100 will be coerced to 100. - int32 page_size = 3; - - // The previous PredictResponse.next_page_token. - string page_token = 4; - - // Filter for restricting prediction results with a length limit of 5,000 - // characters. Accepts values for tags and the `filterOutOfStockItems` flag. - // - // * Tag expressions. Restricts predictions to products that match all of the - // specified tags. Boolean operators `OR` and `NOT` are supported if the - // expression is enclosed in parentheses, and must be separated from the - // tag values by a space. `-"tagA"` is also supported and is equivalent to - // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - // with a size limit of 1,000 characters. - // - // Note: "Recently viewed" models don't support tag filtering at the - // moment. - // - // * filterOutOfStockItems. Restricts predictions to products that do not - // have a - // stockState value of OUT_OF_STOCK. - // - // Examples: - // - // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - // * filterOutOfStockItems tag=(-"promotional") - // * filterOutOfStockItems - // - // If your filter blocks all prediction results, the API will return generic - // (unfiltered) popular products. If you only want results strictly matching - // the filters, set `strictFiltering` to True in `PredictRequest.params` to - // receive empty results instead. - // Note that the API will never return items with storageStatus of "EXPIRED" - // or "DELETED" regardless of filter choices. - string filter = 5; - - // Use validate only mode for this prediction query. If set to true, a - // dummy model will be used that returns arbitrary products. - // Note that the validate only mode should only be used for testing the API, - // or if the model is not ready. - bool validate_only = 6; - - // Additional domain specific parameters for the predictions. - // - // Allowed values: - // - // * `returnProduct`: Boolean. If set to true, the associated product - // object will be returned in the `results.metadata` field in the - // prediction response. - // * `returnScore`: Boolean. If set to true, the prediction 'score' - // corresponding to each returned product will be set in the - // `results.metadata` field in the prediction response. The given - // 'score' indicates the probability of an product being clicked/purchased - // given the user's context and history. - // * `strictFiltering`: Boolean. True by default. If set to false, the service - // will return generic (unfiltered) popular products instead of empty if - // your filter blocks all prediction results. - // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-price-reranking', 'low-price-reranking', - // 'medium-price-reranking', 'high-price-reranking'}. This gives - // request-level control and adjusts prediction results based on product - // price. - // * `diversityLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-diversity', 'low-diversity', - // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - // request-level control and adjusts prediction results based on product - // category. - map params = 7; - - // The labels applied to a resource must meet the following requirements: - // - // * Each resource can have multiple labels, up to a maximum of 64. - // * Each label must be a key-value pair. - // * Keys have a minimum length of 1 character and a maximum length of 63 - // characters, and cannot be empty. Values can be empty, and have a maximum - // length of 63 characters. - // * Keys and values can contain only lowercase letters, numeric characters, - // underscores, and dashes. All characters must use UTF-8 encoding, and - // international characters are allowed. - // * The key portion of a label must be unique. However, you can use the same - // key with multiple resources. - // * Keys must start with a lowercase letter or international character. - // - // See [Google Cloud - // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - // for more details. - map labels = 8; -} - -// Response message for predict method. -message PredictResponse { - // PredictionResult represents the recommendation prediction results. - message PredictionResult { - // ID of the recommended product - string id = 1; - - // Additional product metadata / annotations. - // - // Possible values: - // - // * `product`: JSON representation of the product. Will be set if - // `returnProduct` is set to true in `PredictRequest.params`. - // * `score`: Prediction score in double value. Will be set if - // `returnScore` is set to true in `PredictRequest.params`. - map metadata = 2; - } - - // A list of recommended products. The order represents the ranking (from the - // most relevant product to the least). - repeated PredictionResult results = 1; - - // A unique attribution token. This should be included in the - // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this - // recommendation, which enables accurate attribution of recommendation model - // performance. - string attribution_token = 2; - - // IDs of products in the request that were missing from the inventory. - repeated string missing_ids = 3; - - // True if the validateOnly property was set in the request. - bool validate_only = 4; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto deleted file mode 100644 index cbadc568..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product.proto +++ /dev/null @@ -1,567 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/promotion.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; -option (google.api.resource_definition) = { - type: "retail.googleapis.com/Branch" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" -}; - -// Product captures all metadata information of items to be recommended or -// searched. -message Product { - option (google.api.resource) = { - type: "retail.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" - }; - - // The type of this product. - enum Type { - // Default value. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] - // if unset. - TYPE_UNSPECIFIED = 0; - - // The primary type. - // - // As the primary unit for predicting, indexing and search serving, a - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product] is grouped with multiple - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s. - PRIMARY = 1; - - // The variant type. - // - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s usually share some common - // attributes on the same - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s, but they have variant - // attributes like different colors, sizes and prices, etc. - VARIANT = 2; - - // The collection type. Collection products are bundled - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s or - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s that are sold together, - // such as a jewelry set with necklaces, earrings and rings, etc. - COLLECTION = 3; - } - - // Product availability. If this field is unspecified, the product is - // assumed to be in stock. - enum Availability { - // Default product availability. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK] - // if unset. - AVAILABILITY_UNSPECIFIED = 0; - - // Product in stock. - IN_STOCK = 1; - - // Product out of stock. - OUT_OF_STOCK = 2; - - // Product that is in pre-order state. - PREORDER = 3; - - // Product that is back-ordered (i.e. temporarily out of stock). - BACKORDER = 4; - } - - oneof expiration { - // The timestamp when this product becomes unavailable for - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // If it is set, the [Product][google.cloud.retail.v2alpha.Product] is not - // available for - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] - // after [expire_time][google.cloud.retail.v2alpha.Product.expire_time]. - // However, the product can still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] must be - // later than - // [available_time][google.cloud.retail.v2alpha.Product.available_time] and - // [publish_time][google.cloud.retail.v2alpha.Product.publish_time], - // otherwise an INVALID_ARGUMENT error is thrown. - // - // Corresponding properties: Google Merchant Center property - // [expiration_date](https://support.google.com/merchants/answer/6324499). - google.protobuf.Timestamp expire_time = 16; - - // Input only. The TTL (time to live) of the product. - // - // If it is set, it must be a non-negative value, and - // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is set as - // current timestamp plus [ttl][google.cloud.retail.v2alpha.Product.ttl]. - // The derived - // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is - // returned in the output and [ttl][google.cloud.retail.v2alpha.Product.ttl] - // is left blank when retrieving the - // [Product][google.cloud.retail.v2alpha.Product]. - // - // If it is set, the product is not available for - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] - // after current timestamp plus - // [ttl][google.cloud.retail.v2alpha.Product.ttl]. However, the product can - // still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - google.protobuf.Duration ttl = 17 - [(google.api.field_behavior) = INPUT_ONLY]; - } - - // Immutable. Full resource name of the product, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. [Product][google.cloud.retail.v2alpha.Product] identifier, which - // is the final component of [name][google.cloud.retail.v2alpha.Product.name]. - // For example, this field is "id_1", if - // [name][google.cloud.retail.v2alpha.Product.name] is - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [id](https://support.google.com/merchants/answer/6324405). Schema.org - // property [Product.sku](https://schema.org/sku). - string id = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The type of the product. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] - // if unset. - Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; - - // Variant group identifier. Must be an - // [id][google.cloud.retail.v2alpha.Product.id], with the same parent branch - // with this product. Otherwise, an error is thrown. - // - // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s, this field can only be - // empty or set to the same value as - // [id][google.cloud.retail.v2alpha.Product.id]. - // - // For VARIANT [Product][google.cloud.retail.v2alpha.Product]s, this field - // cannot be empty. A maximum of 2,000 products are allowed to share the same - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [item_group_id](https://support.google.com/merchants/answer/6324507). - // Schema.org property - // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). - string primary_product_id = 4; - - // The [id][google.cloud.retail.v2alpha.Product.id] of the collection members - // when [type][google.cloud.retail.v2alpha.Product.type] is - // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]. - // - // Non-existent product ids are allowed. - // The [type][google.cloud.retail.v2alpha.Product.type] of the members must be - // either [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] or - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] otherwise - // and INVALID_ARGUMENT error is thrown. Should not set it for other types. A - // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is - // return. - repeated string collection_member_ids = 5; - - // The Global Trade Item Number (GTIN) of the product. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Corresponding properties: Google Merchant Center property - // [gtin](https://support.google.com/merchants/answer/6324461). - // Schema.org property - // [Product.isbn](https://schema.org/isbn), - // [Product.gtin8](https://schema.org/gtin8), - // [Product.gtin12](https://schema.org/gtin12), - // [Product.gtin13](https://schema.org/gtin13), or - // [Product.gtin14](https://schema.org/gtin14). - // - // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. - string gtin = 6; - - // Product categories. This field is repeated for supporting one product - // belonging to several parallel categories. Strongly recommended using the - // full path for better search / recommendation quality. - // - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // For example, if a shoes product belongs to both - // ["Shoes & Accessories" -> "Shoes"] and - // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be - // represented as: - // - // "categories": [ - // "Shoes & Accessories > Shoes", - // "Sports & Fitness > Athletic Clothing > Shoes" - // ] - // - // Must be set for - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product] otherwise an - // INVALID_ARGUMENT error is returned. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2alpha.Product]. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [google_product_category][mc_google_product_category]. Schema.org property - // [Product.category] (https://schema.org/category). - // - // [mc_google_product_category]: - // https://support.google.com/merchants/answer/6324436 - repeated string categories = 7; - - // Required. Product title. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [title](https://support.google.com/merchants/answer/6324415). Schema.org - // property [Product.name](https://schema.org/name). - string title = 8 [(google.api.field_behavior) = REQUIRED]; - - // The brands of the product. - // - // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded - // string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [brand](https://support.google.com/merchants/answer/6324351). Schema.org - // property [Product.brand](https://schema.org/brand). - repeated string brands = 9; - - // Product description. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [description](https://support.google.com/merchants/answer/6324468). - // Schema.org property [Product.description](https://schema.org/description). - string description = 10; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // - // For product prediction, this field is ignored and the model automatically - // detects the text language. The - // [Product][google.cloud.retail.v2alpha.Product] can include text in - // different languages, but duplicating - // [Product][google.cloud.retail.v2alpha.Product]s to provide text in multiple - // languages can result in degraded model performance. - // - // For product search this field is in use. It defaults to "en-US" if unset. - string language_code = 11; - - // Highly encouraged. Extra product attributes to be included. For example, - // for products, this could include the store name, vendor, style, color, etc. - // These are very strong signals for recommendation model, thus we highly - // recommend providing the attributes here. - // - // Features that can take on one of a limited number of possible values. Two - // types of features can be set are: - // - // Textual features. some examples would be the brand/maker of a product, or - // country of a customer. Numerical features. Some examples would be the - // height/weight of a product, or age of a customer. - // - // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, - // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} - // }`. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * Max entries count: 200. - // * The key must be a UTF-8 encoded string with a length limit of 128 - // characters. - // * For indexable attribute, the key must match the pattern: - // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or - // `KEY_1_LIKE_THIS`. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a non-empty UTF-8 encoded string with a - // length limit of 256 characters. - // * For number attributes, at most 400 values are allowed. - map attributes = 12; - - // Custom tags associated with the product. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2alpha.Product]. This value must be a UTF-8 - // encoded string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This tag can be used for filtering recommendation results by passing the - // tag as part of the - // [PredictRequest.filter][google.cloud.retail.v2alpha.PredictRequest.filter]. - // - // Corresponding properties: Google Merchant Center property - // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). - repeated string tags = 13; - - // Product price and cost information. - // - // Corresponding properties: Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 14; - - // The rating of this product. - Rating rating = 15; - - // The timestamp when this [Product][google.cloud.retail.v2alpha.Product] - // becomes available for - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - google.protobuf.Timestamp available_time = 18; - - // The online availability of the - // [Product][google.cloud.retail.v2alpha.Product]. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK]. - // - // Corresponding properties: Google Merchant Center property - // [availability](https://support.google.com/merchants/answer/6324448). - // Schema.org property [Offer.availability](https://schema.org/availability). - Availability availability = 19; - - // The available quantity of the item. - google.protobuf.Int32Value available_quantity = 20; - - // Fulfillment information, such as the store IDs for in-store pickup or - // region IDs for different shipping methods. - // - // All the elements must have distinct - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated FulfillmentInfo fulfillment_info = 21; - - // Canonical URL directly linking to the product detail page. - // - // It is strongly recommended to provide a valid uri for the product, - // otherwise the service performance could be significantly degraded. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [link](https://support.google.com/merchants/answer/6324416). Schema.org - // property [Offer.url](https://schema.org/url). - string uri = 22; - - // Product images for the product. We highly recommend putting the main - // image first. - // - // A maximum of 300 images are allowed. - // - // Corresponding properties: Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - repeated Image images = 23; - - // The target group associated with a given audience (e.g. male, veterans, - // car owners, musicians, etc.) of the product. - Audience audience = 24; - - // The color of the product. - // - // Corresponding properties: Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - ColorInfo color_info = 25; - - // The size of the product. To represent different size systems or size types, - // consider using this format: [[[size_system:]size_type:]size_value]. - // - // For example, in "US:MENS:M", "US" represents size system; "MENS" represents - // size type; "M" represents size value. In "GIRLS:27", size system is empty; - // "GIRLS" represents size type; "27" represents size value. In "32 inches", - // both size system and size type are empty, while size value is "32 inches". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [size](https://support.google.com/merchants/answer/6324492), - // [size_type](https://support.google.com/merchants/answer/6324497), and - // [size_system](https://support.google.com/merchants/answer/6324502). - // Schema.org property [Product.size](https://schema.org/size). - repeated string sizes = 26; - - // The material of the product. For example, "leather", "wooden". - // - // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 200 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [material](https://support.google.com/merchants/answer/6324410). Schema.org - // property [Product.material](https://schema.org/material). - repeated string materials = 27; - - // The pattern or graphic print of the product. For example, "striped", "polka - // dot", "paisley". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org - // property [Product.pattern](https://schema.org/pattern). - repeated string patterns = 28; - - // The condition of the product. Strongly encouraged to use the standard - // values: "new", "refurbished", "used". - // - // A maximum of 1 value is allowed per - // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [condition](https://support.google.com/merchants/answer/6324469). - // Schema.org property - // [Offer.itemCondition](https://schema.org/itemCondition). - repeated string conditions = 29; - - // The promotions applied to the product. A maximum of 10 values are allowed - // per [Product][google.cloud.retail.v2alpha.Product]. Only - // [Promotion.promotion_id][google.cloud.retail.v2alpha.Promotion.promotion_id] - // will be used, other fields will be ignored if set. - repeated Promotion promotions = 34; - - // The timestamp when the product is published by the retailer for the first - // time, which indicates the freshness of the products. Note that this field - // is different from - // [available_time][google.cloud.retail.v2alpha.Product.available_time], given - // it purely describes product freshness regardless of when it is available on - // search and recommendation. - google.protobuf.Timestamp publish_time = 33; - - // Indicates which fields in the - // [Product][google.cloud.retail.v2alpha.Product]s are returned in - // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse]. - // - // Supported fields for all [type][google.cloud.retail.v2alpha.Product.type]s: - // - // * [audience][google.cloud.retail.v2alpha.Product.audience] - // * [availability][google.cloud.retail.v2alpha.Product.availability] - // * [brands][google.cloud.retail.v2alpha.Product.brands] - // * [color_info][google.cloud.retail.v2alpha.Product.color_info] - // * [conditions][google.cloud.retail.v2alpha.Product.conditions] - // * [gtin][google.cloud.retail.v2alpha.Product.gtin] - // * [materials][google.cloud.retail.v2alpha.Product.materials] - // * [name][google.cloud.retail.v2alpha.Product.name] - // * [patterns][google.cloud.retail.v2alpha.Product.patterns] - // * [price_info][google.cloud.retail.v2alpha.Product.price_info] - // * [rating][google.cloud.retail.v2alpha.Product.rating] - // * [sizes][google.cloud.retail.v2alpha.Product.sizes] - // * [title][google.cloud.retail.v2alpha.Product.title] - // * [uri][google.cloud.retail.v2alpha.Product.uri] - // - // Supported fields only for - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]: - // - // * [categories][google.cloud.retail.v2alpha.Product.categories] - // * [description][google.cloud.retail.v2alpha.Product.description] - // * [images][google.cloud.retail.v2alpha.Product.images] - // - // Supported fields only for - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]: - // - // * Only the first image in - // [images][google.cloud.retail.v2alpha.Product.images] - // - // To mark [attributes][google.cloud.retail.v2alpha.Product.attributes] as - // retrievable, include paths of the form "attributes.key" where "key" is the - // key of a custom attribute, as specified in - // [attributes][google.cloud.retail.v2alpha.Product.attributes]. - // - // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], the - // following fields are always returned in - // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] by default: - // - // * [name][google.cloud.retail.v2alpha.Product.name] - // - // For [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT], the - // following fields are always returned in by default: - // - // * [name][google.cloud.retail.v2alpha.Product.name] - // * [color_info][google.cloud.retail.v2alpha.Product.color_info] - // - // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Note: Returning more fields in - // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] may increase - // response payload size and serving latency. - google.protobuf.FieldMask retrievable_fields = 30; - - // Output only. Product variants grouped together on primary product which - // share similar product attributes. It's automatically grouped by - // [primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] - // for all the product variants. Only populated for - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. - // Do not set this field in API requests. - repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto deleted file mode 100644 index 7bced3fb..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto +++ /dev/null @@ -1,882 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/import_config.proto"; -import "google/cloud/retail/v2alpha/product.proto"; -import "google/cloud/retail/v2alpha/purge_config.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for ingesting [Product][google.cloud.retail.v2alpha.Product] -// information of the customer's website. -service ProductService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a [Product][google.cloud.retail.v2alpha.Product]. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Gets a [Product][google.cloud.retail.v2alpha.Product]. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Product][google.cloud.retail.v2alpha.Product]s. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a [Product][google.cloud.retail.v2alpha.Product]. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v2alpha/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Deletes a [Product][google.cloud.retail.v2alpha.Product]. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Permanently deletes all selected - // [Product][google.cloud.retail.v2alpha.Product]s under a branch. - // - // This process is asynchronous. If the request is valid, the removal will be - // enqueued and processed offline. Depending on the number of - // [Product][google.cloud.retail.v2alpha.Product]s, this operation could take - // hours to complete. Before the operation completes, some - // [Product][google.cloud.retail.v2alpha.Product]s may still be returned by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, - // this operation could take hours to complete. To get a sample of - // [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set - // [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] - // to false. - rpc PurgeProducts(PurgeProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:purge" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.PurgeProductsResponse" - metadata_type: "google.cloud.retail.v2alpha.PurgeProductsMetadata" - }; - } - - // Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. - // - // Request processing may be synchronous. No partial updating is supported. - // Non-existing items are created. - // - // Note that it is possible for a subset of the - // [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated. - rpc ImportProducts(ImportProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.ImportProductsResponse" - metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" - }; - } - - // Updates inventory information for a - // [Product][google.cloud.retail.v2alpha.Product] while respecting the last - // update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2alpha.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, updates are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // When inventory is updated with - // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], - // the specified inventory field value(s) will overwrite any existing value(s) - // while ignoring the last update time for this field. Furthermore, the last - // update time for the specified inventory fields will be overwritten to the - // time of the - // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // or - // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] - // request. - // - // If no inventory fields are set in - // [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], - // then any pre-existing inventory information for this product will be used. - // - // If no inventory fields are set in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], - // then any existing inventory information will be preserved. - // - // Pre-existing inventory information can only be updated with - // [SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], - // [AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], - // and - // [RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" - body: "*" - }; - option (google.api.method_signature) = "inventory,set_mask"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.SetInventoryResponse" - metadata_type: "google.cloud.retail.v2alpha.SetInventoryMetadata" - }; - } - - // Incrementally adds place IDs to - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2alpha.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the added place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata" - }; - } - - // Incrementally removes place IDs from a - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2alpha.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the removed place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata" - }; - } - - // Updates local inventory information for a - // [Product][google.cloud.retail.v2alpha.Product] at a list of places, while - // respecting the last update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2alpha.Product] to exist before updating - // inventory information. If the request is valid, the update will be enqueued - // and processed downstream. As a consequence, when a response is returned, - // updates are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // Local inventory information can only be modified using this method. - // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddLocalInventories(AddLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.AddLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2alpha.AddLocalInventoriesMetadata" - }; - } - - // Remove local inventory information for a - // [Product][google.cloud.retail.v2alpha.Product] at a list of places at a - // removal timestamp. - // - // This process is asynchronous. If the request is valid, the removal will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, removals are not immediately manifested in the - // [Product][google.cloud.retail.v2alpha.Product] queried by - // [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // Local inventory information can only be removed using this method. - // [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata" - }; - } -} - -// Request message for [CreateProduct][] method. -message CreateProductRequest { - // Required. The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Required. The [Product][google.cloud.retail.v2alpha.Product] to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the - // [Product][google.cloud.retail.v2alpha.Product], which will become the final - // component of the [Product.name][google.cloud.retail.v2alpha.Product.name]. - // - // If the caller does not have permission to create the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // This field must be unique among all - // [Product][google.cloud.retail.v2alpha.Product]s with the same - // [parent][google.cloud.retail.v2alpha.CreateProductRequest.parent]. - // Otherwise, an ALREADY_EXISTS error is returned. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string product_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [GetProduct][] method. -message GetProductRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // If the requested [Product][google.cloud.retail.v2alpha.Product] does not - // exist, a NOT_FOUND error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for [UpdateProduct][] method. -message UpdateProductRequest { - // Required. The product to update/create. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2alpha.Product] to update does not - // exist and - // [allow_missing][google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing] - // is not set, a NOT_FOUND error is returned. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Product][google.cloud.retail.v2alpha.Product] to update. The immutable and - // output only fields are NOT supported. If not set, all supported fields (the - // fields that are neither immutable nor output only) are updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, a new [Product][google.cloud.retail.v2alpha.Product] will be - // created. In this situation, `update_mask` is ignored. - bool allow_missing = 3; -} - -// Request message for [DeleteProduct][] method. -message DeleteProductRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to delete the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2alpha.Product] to delete does not - // exist, a NOT_FOUND error is returned. - // - // The [Product][google.cloud.retail.v2alpha.Product] to delete can neither be - // a - // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2alpha.Product] member nor a - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product] with more than one - // [variants][google.cloud.retail.v2alpha.Product.Type.VARIANT]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // All inventory information for the named - // [Product][google.cloud.retail.v2alpha.Product] will be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for -// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] -// method. -message ListProductsRequest { - // Required. The parent branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use - // `default_branch` as the branch ID, to list products under the default - // branch. - // - // If the caller does not have permission to list - // [Product][google.cloud.retail.v2alpha.Product]s under this branch, - // regardless of whether or not this branch exists, a PERMISSION_DENIED error - // is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to - // return. If unspecified, defaults to 100. The maximum allowed value is 1000. - // Values above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT error is returned. - int32 page_size = 2; - - // A page token - // [ListProductsResponse.next_page_token][google.cloud.retail.v2alpha.ListProductsResponse.next_page_token], - // received from a previous - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; - - // A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2alpha.ListProductsRequest.filter] is unset. - // * List - // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s sharing the same - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product]. For example: - // `primary_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2alpha.Product]s bundled in a - // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2alpha.Product]. - // For example: - // `collection_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2alpha.Product]s with a partibular - // type. For example: - // `type = "PRIMARY"` - // `type = "VARIANT"` - // `type = "COLLECTION"` - // - // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - // - // If the specified - // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2alpha.Product] or - // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2alpha.Product] does not exist, a NOT_FOUND - // error is returned. - string filter = 4; - - // The fields of [Product][google.cloud.retail.v2alpha.Product] to return in - // the responses. If not set or empty, the following fields are returned: - // - // * [Product.name][google.cloud.retail.v2alpha.Product.name] - // * [Product.id][google.cloud.retail.v2alpha.Product.id] - // * [Product.title][google.cloud.retail.v2alpha.Product.title] - // * [Product.uri][google.cloud.retail.v2alpha.Product.uri] - // * [Product.images][google.cloud.retail.v2alpha.Product.images] - // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] - // * [Product.brands][google.cloud.retail.v2alpha.Product.brands] - // - // If "*" is provided, all fields are returned. - // [Product.name][google.cloud.retail.v2alpha.Product.name] is always returned - // no matter what mask is set. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask read_mask = 5; - - // If true and - // [page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] is - // empty, - // [ListProductsResponse.total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] - // is set to the total count of matched items irrespective of pagination. - // - // Notice that setting this field to true affects the performance. - bool require_total_size = 6; -} - -// Response message for -// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] -// method. -message ListProductsResponse { - // The [Product][google.cloud.retail.v2alpha.Product]s. - repeated Product products = 1; - - // A token that can be sent as - // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; - - // The total count of matched [Product][google.cloud.retail.v2alpha.Product]s - // irrespective of pagination. The total number of - // [Product][google.cloud.retail.v2alpha.Product]s returned by pagination may - // be less than the - // [total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] - // that matches. - // - // This field is ignored if - // [ListProductsRequest.require_total_size][google.cloud.retail.v2alpha.ListProductsRequest.require_total_size] - // is not set or - // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] - // is not empty. - int32 total_size = 3; -} - -// Request message for [SetInventory][] method. -message SetInventoryRequest { - // Required. The inventory information to update. The allowable fields to - // update are: - // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] - // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] - // The updated inventory fields must be specified in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask]. - // - // If [SetInventoryRequest.inventory.name][] is empty or invalid, an - // INVALID_ARGUMENT error is returned. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2alpha.Product] named in - // [Product.name][google.cloud.retail.v2alpha.Product.name], regardless of - // whether or not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2alpha.Product] to update does not - // have existing inventory information, the provided inventory information - // will be inserted. - // - // If the [Product][google.cloud.retail.v2alpha.Product] to update has - // existing inventory information, the provided inventory information will be - // merged while respecting the last update time for each inventory field, - // using the provided or default value for - // [SetInventoryRequest.set_time][google.cloud.retail.v2alpha.SetInventoryRequest.set_time]. - // - // The caller can replace place IDs for a subset of fulfillment types in the - // following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types and corresponding place IDs - // to update in [SetInventoryRequest.inventory.fulfillment_info][] - // - // The caller can clear all place IDs from a subset of fulfillment types in - // the following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types to clear in - // [SetInventoryRequest.inventory.fulfillment_info][] - // * Checks that only the desired fulfillment info types have empty - // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] - // - // The last update time is recorded for the following inventory fields: - // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] - // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] - // - // If a full overwrite of inventory information while ignoring timestamps is - // needed, [UpdateProduct][] should be invoked instead. - Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided - // [Product][google.cloud.retail.v2alpha.Product] to update. - // - // At least one field must be provided. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask set_mask = 2; - - // The time when the request is issued, used to prevent - // out-of-order updates on inventory fields with the last update time - // recorded. If not provided, the internal system time will be used. - google.protobuf.Timestamp set_time = 3; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] with - // name [Product.name][google.cloud.retail.v2alpha.Product.name] is not found, - // the inventory update will still be processed and retained for at most 1 day - // until the [Product][google.cloud.retail.v2alpha.Product] is created. If set - // to false, a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 4; -} - -// Metadata related to the progress of the SetInventory operation. -// Currently empty because there is no meaningful metadata populated from the -// [SetInventory][] method. -message SetInventoryMetadata {} - -// Response of the SetInventoryRequest. Currently empty because -// there is no meaningful response populated from the [SetInventory][] -// method. -message SetInventoryResponse {} - -// Request message for [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type], such - // as the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery" to be added for this - // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type]. - // Duplicate IDs will be automatically ignored. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // If the total number of place IDs exceeds 2000 for this - // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type] after - // adding, then the update will be rejected. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, the fulfillment information will still be processed and retained - // for at most 1 day and processed once the - // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the AddFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesMetadata {} - -// Response of the AddFulfillmentPlacesRequest. Currently empty because -// there is no meaningful response populated from the [AddFulfillmentPlaces][] -// method. -message AddFulfillmentPlacesResponse {} - -// Request message for [AddLocalInventories][] method. -message AddLocalInventoriesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of inventory information at difference places. Each place - // is identified by its place ID. At most 3000 inventories are allowed per - // request. - repeated LocalInventory local_inventories = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided list of - // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory] to update. The - // field is updated to the provided value. - // - // If a field is set while the place does not have a previous local inventory, - // the local inventory at that store is created. - // - // If a field is set while the value of that field is not provided, the - // original field value, if it exists, is deleted. - // - // If the mask is not set or set with empty paths, all inventory fields will - // be updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask add_mask = 4; - - // The time when the inventory updates are issued. Used to prevent - // out-of-order updates on local inventory fields. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, the local inventory will still be processed and retained for at - // most 1 day and processed once the - // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 6; -} - -// Metadata related to the progress of the AddLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddLocalInventories][] method. -message AddLocalInventoriesMetadata {} - -// Response of the [AddLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [AddLocalInventories][] -// method. -message AddLocalInventoriesResponse {} - -// Request message for [RemoveLocalInventories][] method. -message RemoveLocalInventoriesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of place IDs to have their inventory deleted. - // At most 3000 place IDs are allowed per request. - repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; - - // The time when the inventory deletions are issued. Used to prevent - // out-of-order updates and deletions on local inventory fields. If not - // provided, the internal system time will be used. - google.protobuf.Timestamp remove_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, the local inventory removal request will still be processed and - // retained for at most 1 day and processed once the - // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 3; -} - -// Metadata related to the progress of the RemoveLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveLocalInventories][] method. -message RemoveLocalInventoriesMetadata {} - -// Response of the [RemoveLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [RemoveLocalInventories][] -// method. -message RemoveLocalInventoriesResponse {} - -// Request message for [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2alpha.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or - // not it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type], - // such as the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery", to be removed for this - // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type]. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp remove_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is - // not found, the fulfillment information will still be processed and retained - // for at most 1 day and processed once the - // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2alpha.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the RemoveFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesMetadata {} - -// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there -// is no meaningful response populated from the [RemoveFulfillmentPlaces][] -// method. -message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto deleted file mode 100644 index 879449a4..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "PromotionProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Promotion information. -message Promotion { - // ID of the promotion. For example, "free gift". - // - // The value must be a UTF-8 encoded string with a length limit of 128 - // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, - // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Google Merchant Center property - // [promotion](https://support.google.com/merchants/answer/7050148). - string promotion_id = 1; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto deleted file mode 100644 index 6b929f26..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "PurgeConfigProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Metadata related to the progress of the Purge operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeMetadata {} - -// Metadata related to the progress of the PurgeProducts operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeProductsMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were deleted successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; -} - -// Request message for PurgeProducts method. -message PurgeProductsRequest { - // Required. The resource name of the branch under which the products are - // created. The format is - // `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Required. The filter string to specify the products to be deleted with a - // length limit of 5,000 characters. - // - // Empty string filter is not allowed. "*" implies delete all items in a - // branch. - // - // The eligible fields for filtering are: - // - // * `availability`: Double quoted - // [Product.availability][google.cloud.retail.v2alpha.Product.availability] - // string. - // * `create_time` : in ISO 8601 "zulu" format. - // - // Supported syntax: - // - // * Comparators (">", "<", ">=", "<=", "="). - // Examples: - // * create_time <= "2015-02-13T17:05:46Z" - // * availability = "IN_STOCK" - // - // * Conjunctions ("AND") - // Examples: - // * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" - // - // * Disjunctions ("OR") - // Examples: - // * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" - // - // * Can support nested queries. - // Examples: - // * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") - // OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") - // - // * Filter Limits: - // * Filter should not contain more than 6 conditions. - // * Max nesting depth should not exceed 2 levels. - // - // Examples queries: - // * Delete back order products created before a timestamp. - // create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually perform the purge. - // If `force` is set to false, the method will return the expected purge count - // without deleting any products. - bool force = 3; -} - -// Response of the PurgeProductsRequest. If the long running operation is -// successfully done, then this message is returned by the -// google.longrunning.Operations.response field. -message PurgeProductsResponse { - // The total count of products purged as a result of the operation. - int64 purge_count = 1; - - // A sample of the product names that will be deleted. - // Only populated if `force` is set to false. A max of 100 names will be - // returned and the names are chosen at random. - repeated string purge_sample = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for PurgeUserEvents method. -message PurgeUserEventsRequest { - // Required. The resource name of the catalog under which the events are - // created. The format is - // `projects/${projectId}/locations/global/catalogs/${catalogId}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The filter string to specify the events to be deleted with a - // length limit of 5,000 characters. Empty string filter is not allowed. The - // eligible fields for filtering are: - // - // * `eventType`: Double quoted - // [UserEvent.event_type][google.cloud.retail.v2alpha.UserEvent.event_type] - // string. - // * `eventTime`: in ISO 8601 "zulu" format. - // * `visitorId`: Double quoted string. Specifying this will delete all - // events associated with a visitor. - // * `userId`: Double quoted string. Specifying this will delete all events - // associated with a user. - // - // Examples: - // - // * Deleting all events in a time range: - // `eventTime > "2012-04-23T18:25:43.511Z" - // eventTime < "2012-04-23T18:30:43.511Z"` - // * Deleting specific eventType in time range: - // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - // * Deleting all events for a specific visitor: - // `visitorId = "visitor1024"` - // - // The filtering fields are assumed to have an implicit AND. - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually perform the purge. - // If `force` is set to false, the method will return the expected purge count - // without deleting any user events. - bool force = 3; -} - -// Response of the PurgeUserEventsRequest. If the long running operation is -// successfully done, then this message is returned by the -// google.longrunning.Operations.response field. -message PurgeUserEventsResponse { - // The total count of events purged as a result of the operation. - int64 purged_events_count = 1; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto deleted file mode 100644 index f9612734..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto +++ /dev/null @@ -1,832 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/product.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "SearchServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for search. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service SearchService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Performs a search. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc Search(SearchRequest) returns (SearchResponse) { - option (google.api.http) = { - post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" - body: "*" - }; - } -} - -// Request message for -// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] -// method. -message SearchRequest { - // A facet specification to perform faceted search. - message FacetSpec { - // Specifies how a facet is computed. - message FacetKey { - // Required. Supported textual and numerical facet keys in - // [Product][google.cloud.retail.v2alpha.Product] object, over which the - // facet values are computed. Facet key is case-sensitive. - // - // Allowed facet keys when - // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] - // is not specified: - // - // * textual_field = - // * "brands" - // * "categories" - // * "genders" - // * "ageGroups" - // * "availability" - // * "colorFamilies" - // * "colors" - // * "sizes" - // * "materials" - // * "patterns" - // * "conditions" - // * "attributes.key" - // * "pickupInStore" - // * "shipToStore" - // * "sameDayDelivery" - // * "nextDayDelivery" - // * "customFulfillment1" - // * "customFulfillment2" - // * "customFulfillment3" - // * "customFulfillment4" - // * "customFulfillment5" - // * "inventory(place_id,attributes.key)" - // - // * numerical_field = - // * "price" - // * "discount" - // * "rating" - // * "ratingCount" - // * "attributes.key" - // * "inventory(place_id,price)" - // * "inventory(place_id,original_price)" - // * "inventory(place_id,attributes.key)" - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Set only if values should be bucketized into intervals. Must be set - // for facets with numerical values. Must not be set for facet with text - // values. Maximum number of intervals is 30. - repeated Interval intervals = 2; - - // Only get facet for the given restricted values. For example, when using - // "pickupInStore" as key and set restricted values to - // ["store123", "store456"], only facets for "store123" and "store456" are - // returned. Only supported on textual fields and fulfillments. - // Maximum is 20. - // - // Must be set for the fulfillment facet keys: - // - // * pickupInStore - // - // * shipToStore - // - // * sameDayDelivery - // - // * nextDayDelivery - // - // * customFulfillment1 - // - // * customFulfillment2 - // - // * customFulfillment3 - // - // * customFulfillment4 - // - // * customFulfillment5 - repeated string restricted_values = 3; - - // Only get facet values that start with the given string prefix. For - // example, suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the - // "categories" facet will give only "Women > Shoe" and "Women > Dress". - // Only supported on textual fields. Maximum is 10. - repeated string prefixes = 8; - - // Only get facet values that contains the given strings. For example, - // suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the - // "categories" facet will give only "Women > Shoe" and "Men > Shoe". - // Only supported on textual fields. Maximum is 10. - repeated string contains = 9; - - // The order in which [Facet.values][] are returned. - // - // Allowed values are: - // - // * "count desc", which means order by [Facet.FacetValue.count][] - // descending. - // - // * "value desc", which means order by [Facet.FacetValue.value][] - // descending. - // Only applies to textual facets. - // - // If not set, textual values are sorted in [natural - // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical - // intervals are sorted in the order given by - // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.intervals]; - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // are sorted in the order given by - // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.restricted_values]. - string order_by = 4; - - // The query that is used to compute facet for the given facet key. - // When provided, it will override the default behavior of facet - // computation. The query syntax is the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for detail syntax and limitations. Notice that there is no limitation - // on - // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] - // when query is specified. - // - // In the response, [FacetValue.value][] will be always "1" and - // [FacetValue.count][] will be the number of results that matches the - // query. - // - // For example, you can set a customized facet for "shipToStore", - // where - // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] - // is "customizedShipToStore", and - // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] - // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". - // Then the facet will count the products that are both in stock and ship - // to store "123". - string query = 5; - } - - // Required. The facet key specification. - FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum of facet values that should be returned for this facet. If - // unspecified, defaults to 20. The maximum allowed value is 300. Values - // above 300 will be coerced to 300. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 limit = 2; - - // List of keys to exclude when faceting. - // - // By default, - // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] - // is not excluded from the filter unless it is listed in this field. - // - // For example, suppose there are 100 products with color facet "Red" and - // 200 products with color facet "Blue". A query containing the filter - // "colorFamilies:ANY("Red")" and have "colorFamilies" as - // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] - // will by default return the "Red" with count 100. - // - // If this field contains "colorFamilies", then the query returns both the - // "Red" with count 100 and "Blue" with count 200, because the - // "colorFamilies" key is now excluded from the filter. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated string excluded_filter_keys = 3; - - // Enables dynamic position for this facet. If set to true, the position of - // this facet among all facets in the response is determined by Google - // Retail Search. It will be ordered together with dynamic facets if dynamic - // facets is enabled. If set to false, the position of this facet in the - // response will be the same as in the request, and it will be ranked before - // the facets with dynamic position enable and all dynamic facets. - // - // For example, you may always want to have rating facet returned in - // the response, but it's not necessarily to always display the rating facet - // at the top. In that case, you can set enable_dynamic_position to true so - // that the position of rating facet in response will be determined by - // Google Retail Search. - // - // Another example, assuming you have the following facets in the request: - // - // * "rating", enable_dynamic_position = true - // - // * "price", enable_dynamic_position = false - // - // * "brands", enable_dynamic_position = false - // - // And also you have a dynamic facets enable, which will generate a facet - // 'gender'. Then the final order of the facets in the response can be - // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", - // "rating") depends on how Google Retail Search orders "gender" and - // "rating" facets. However, notice that "price" and "brands" will always be - // ranked at 1st and 2nd position since their enable_dynamic_position are - // false. - bool enable_dynamic_position = 4; - } - - // The specifications of dynamically generated facets. - message DynamicFacetSpec { - // Enum to control DynamicFacet mode - enum Mode { - // Default value. - MODE_UNSPECIFIED = 0; - - // Disable Dynamic Facet. - DISABLED = 1; - - // Automatic mode built by Google Retail Search. - ENABLED = 2; - } - - // Mode of the DynamicFacet feature. - // Defaults to - // [Mode.DISABLED][google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode.DISABLED] - // if it's unset. - Mode mode = 1; - } - - // Boost specification to boost certain items. - message BoostSpec { - // Boost applies to products which match a condition. - message ConditionBoostSpec { - // An expression which specifies a boost condition. The syntax and - // supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue": - // * (id: ANY("product_1", "product_2")) AND (colorFamilies: - // ANY("Red","Blue")) - string condition = 1; - - // Strength of the condition boost, which should be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 2; - } - - // Condition boost specifications. If a product matches multiple conditions - // in the specifictions, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 10. - repeated ConditionBoostSpec condition_boost_specs = 1; - - // Whether to skip boostspec validation. If this field is set to true, - // invalid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] - // will be ignored and valid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] - // will still be applied. - optional bool skip_boost_spec_validation = 2; - } - - // Specification to determine under which conditions query expansion should - // occur. - message QueryExpansionSpec { - // Enum describing under which condition query expansion should occur. - enum Condition { - // Unspecified query expansion condition. This defaults to - // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - CONDITION_UNSPECIFIED = 0; - - // Disabled query expansion. Only the exact search query is used, even if - // [SearchResponse.total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] - // is zero. - DISABLED = 1; - - // Automatic query expansion built by Google Retail Search. - AUTO = 3; - } - - // The condition under which query expansion should occur. Default to - // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - Condition condition = 1; - - // Whether to pin unexpanded results. If this field is set to true, - // unexpanded products are always at the top of the search results, followed - // by the expanded results. - bool pin_unexpanded_results = 2; - } - - // The specification for personalization. - message PersonalizationSpec { - // The personalization mode of each search request. - enum Mode { - // Default value. Defaults to - // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Let CRS decide whether to use personalization. - AUTO = 1; - - // Disable personalization. - DISABLED = 2; - } - - // Defaults to - // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. - Mode mode = 1; - } - - // The relevance threshold of the search results. The higher relevance - // threshold is, the higher relevant results are shown and the less number of - // results are returned. - enum RelevanceThreshold { - // Default value. Defaults to - // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH]. - RELEVANCE_THRESHOLD_UNSPECIFIED = 0; - - // High relevance threshold. - HIGH = 1; - - // Medium relevance threshold. - MEDIUM = 2; - - // Low relevance threshold. - LOW = 3; - - // Lowest relevance threshold. - LOWEST = 4; - } - - // The search mode of each search request. - enum SearchMode { - // Default value. In this case both product search and faceted search will - // be performed. Both [SearchResponse.SearchResult] and - // [SearchResponse.Facet] will be returned. - SEARCH_MODE_UNSPECIFIED = 0; - - // Only product search will be performed. The faceted search will be - // disabled. - // - // Only [SearchResponse.SearchResult] will be returned. - // [SearchResponse.Facet] will not be returned, even if - // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] - // or - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] - // is set. - PRODUCT_SEARCH_ONLY = 1; - - // Only faceted search will be performed. The product search will be - // disabled. - // - // When in this mode, one or both of [SearchRequest.facet_spec][] and - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] - // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only - // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] - // will not be returned. - FACETED_SEARCH_ONLY = 2; - } - - // Required. The resource name of the search engine placement, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` - // This field is used to identify the serving configuration name and the set - // of models that will be used to make the search. - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. - // - // Use "default_branch" as the branch ID or leave this field empty, to search - // products under the default branch. - string branch = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Raw search query. - string query = 3; - - // Required. A unique identifier for tracking visitors. For example, this - // could be implemented with an HTTP cookie, which should be able to uniquely - // identify a visitor on a single device. This unique identifier should not - // change if the visitor logs in or out of the website. - // - // This should be the same identifier as - // [UserEvent.visitor_id][google.cloud.retail.v2alpha.UserEvent.visitor_id]. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; - - // User information. - UserInfo user_info = 5; - - // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to - // return. If unspecified, defaults to a reasonable value. The maximum allowed - // value is 120. Values above 120 will be coerced to 120. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 7; - - // A page token - // [SearchResponse.next_page_token][google.cloud.retail.v2alpha.SearchResponse.next_page_token], - // received from a previous - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 8; - - // A 0-indexed integer that specifies the current offset (that is, starting - // result location, amongst the - // [Product][google.cloud.retail.v2alpha.Product]s deemed by the API as - // relevant) in search results. This field is only considered if - // [page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] is - // unset. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 offset = 9; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. Filter - // expression is case-sensitive. See more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string filter = 10; - - // The default filter that is applied when a user performs a search without - // checking any filters on the search page. - // - // The filter applied to every search request when quality improvement such as - // query expansion is needed. For example, if a query does not have enough - // results, an expanded query with - // [SearchRequest.canonical_filter][google.cloud.retail.v2alpha.SearchRequest.canonical_filter] - // will be returned as a supplement of the original query. This field is - // strongly recommended to achieve high search quality. - // - // See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for more details about filter syntax. - string canonical_filter = 28; - - // The order in which products are returned. Products can be ordered by - // a field in an [Product][google.cloud.retail.v2alpha.Product] object. Leave - // it unset if ordered by relevance. OrderBy expression is case-sensitive. See - // more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#order). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string order_by = 11; - - // Facet specifications for faceted search. If empty, no facets are returned. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated FacetSpec facet_specs = 12; - - // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - // to enable dynamic facets. Do not set this field. - // - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; - - // Boost specification to boost certain products. See more details at this - // [user guide](https://cloud.google.com/retail/docs/boosting). - // - // Notice that if both - // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] - // and [SearchRequest.boost_spec] are set, the boost conditions from both - // places are evaluated. If a search request matches multiple boost - // conditions, the final boost score is equal to the sum of the boost scores - // from all matched boost conditions. - BoostSpec boost_spec = 13; - - // The query expansion specification that specifies the conditions under which - // query expansion will occur. See more details at this [user - // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - QueryExpansionSpec query_expansion_spec = 14; - - // The relevance threshold of the search results. - // - // Defaults to - // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH], - // which means only the most relevant results are shown, and the least number - // of results are returned. See more details at this [user - // guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - RelevanceThreshold relevance_threshold = 15; - - // The keys to fetch and rollup the matching - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s attributes, - // [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo] or - // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s attributes. - // The attributes from all the matching - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s or - // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s are merged - // and de-duplicated. Notice that rollup attributes will lead to extra query - // latency. Maximum number of keys is 30. - // - // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], a - // fulfillment type and a fulfillment ID must be provided in the format of - // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - // "pickupInStore" is fulfillment type and "store123" is the store ID. - // - // Supported keys are: - // - // * colorFamilies - // * price - // * originalPrice - // * discount - // * variantId - // * inventory(place_id,price) - // * inventory(place_id,original_price) - // * inventory(place_id,attributes.key), where key is any key in the - // [Product.inventories.attributes][] map. - // * attributes.key, where key is any key in the - // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes] map. - // * pickupInStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "pickup-in-store". - // * shipToStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "ship-to-store". - // * sameDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "same-day-delivery". - // * nextDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "next-day-delivery". - // * customFulfillment1.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-1". - // * customFulfillment2.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-2". - // * customFulfillment3.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-3". - // * customFulfillment4.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-4". - // * customFulfillment5.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] - // for - // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] - // "custom-type-5". - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - repeated string variant_rollup_keys = 17; - - // The categories associated with a category page. Required for category - // navigation queries to achieve good search quality. The format should be - // the same as - // [UserEvent.page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories]; - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - repeated string page_categories = 23; - - // The search mode of the search request. If not specified, a single search - // request triggers both product search and faceted search. - SearchMode search_mode = 31; - - // The specification for personalization. - PersonalizationSpec personalization_spec = 32; -} - -// Response message for -// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] -// method. -message SearchResponse { - // Represents the search results. - message SearchResult { - // [Product.id][google.cloud.retail.v2alpha.Product.id] of the searched - // [Product][google.cloud.retail.v2alpha.Product]. - string id = 1; - - // The product data snippet in the search response. Only - // [Product.name][google.cloud.retail.v2alpha.Product.name] is guaranteed to - // be populated. - // - // [Product.variants][google.cloud.retail.v2alpha.Product.variants] contains - // the product variants that match the search query. If there are multiple - // product variants matching the query, top 5 most relevant product variants - // are returned and ordered by relevancy. - // - // If relevancy can be deternmined, use - // [matching_variant_fields][google.cloud.retail.v2alpha.SearchResponse.SearchResult.matching_variant_fields] - // to look up matched product variants fields. If relevancy cannot be - // determined, e.g. when searching "shoe" all products in a shoe product can - // be a match, 5 product variants are returned but order is meaningless. - Product product = 2; - - // The count of matched - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product]s. - int32 matching_variant_count = 3; - - // If a [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] matches the search query, - // this map indicates which [Product][google.cloud.retail.v2alpha.Product] - // fields are matched. The key is the - // [Product.name][google.cloud.retail.v2alpha.Product.name], the value is a - // field mask of the matched [Product][google.cloud.retail.v2alpha.Product] - // fields. If matched attributes cannot be determined, this map will be - // empty. - // - // For example, a key "sku1" with field mask - // "products.color_info" indicates there is a match between - // "sku1" [ColorInfo][google.cloud.retail.v2alpha.ColorInfo] and the query. - map matching_variant_fields = 4; - - // The rollup matching - // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2alpha.Product] attributes. The key is one - // of the - // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2alpha.SearchRequest.variant_rollup_keys]. - // The values are the merged and de-duplicated - // [Product][google.cloud.retail.v2alpha.Product] attributes. Notice that - // the rollup values are respect filter. For example, when filtering by - // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is - // returned. - // - // For textual and numerical attributes, the rollup values is a list of - // string or double values with type - // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if - // there are two variants with colors "red" and "blue", the rollup values - // are - // - // { key: "colorFamilies" - // value { - // list_value { - // values { string_value: "red" } - // values { string_value: "blue" } - // } - // } - // } - // - // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], the - // rollup values is a double value with type - // [google.protobuf.Value][google.protobuf.Value]. For example, - // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there - // are 10 variants in this product are available in the store "store1". - map variant_rollup_values = 5; - } - - // A facet result. - message Facet { - // A facet value which contains value names and their count. - message FacetValue { - // A facet value which contains values. - oneof facet_value { - // Text value of a facet, such as "Black" for facet "colorFamilies". - string value = 1; - - // Interval value for a facet, such as [10, 20) for facet "price". - Interval interval = 2; - } - - // Number of items that have this facet value. - int64 count = 3; - } - - // The key for this facet. E.g., "colorFamilies" or "price" or - // "attributes.attr1". - string key = 1; - - // The facet values for this field. - repeated FacetValue values = 2; - - // Whether the facet is dynamically generated. - bool dynamic_facet = 3; - } - - // Information describing query expansion including whether expansion has - // occurred. - message QueryExpansionInfo { - // Bool describing whether query expansion has occurred. - bool expanded_query = 1; - - // Number of pinned results. This field will only be set when expansion - // happens and - // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] - // is set to true. - int64 pinned_result_count = 2; - } - - // A list of matched items. The order represents the ranking. - repeated SearchResult results = 1; - - // Results of facets requested by user. - repeated Facet facets = 2; - - // The estimated total count of matched items irrespective of pagination. The - // count of [results][google.cloud.retail.v2alpha.SearchResponse.results] - // returned by pagination may be less than the - // [total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] that - // matches. - int32 total_size = 3; - - // If spell correction applies, the corrected query. Otherwise, empty. - string corrected_query = 4; - - // A unique search token. This should be included in the - // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this - // search, which enables accurate attribution of search model performance. - string attribution_token = 5; - - // A token that can be sent as - // [SearchRequest.page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 6; - - // Query expansion information for the returned results. - QueryExpansionInfo query_expansion_info = 7; - - // The URI of a customer-defined redirect page. If redirect action is - // triggered, no search will be performed, and only - // [redirect_uri][google.cloud.retail.v2alpha.SearchResponse.redirect_uri] and - // [attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] - // will be set in the response. - string redirect_uri = 10; - - // The fully qualified resource name of applied - // [controls](https://cloud.google.com/retail/docs/serving-control-rules). - repeated string applied_controls = 12; - - // The invalid - // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] - // that are not applied during serving. - repeated SearchRequest.BoostSpec.ConditionBoostSpec - invalid_condition_boost_specs = 14; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto deleted file mode 100644 index c339f310..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/search_service.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Configures metadata that is used to generate serving time results (e.g. -// search results or recommendation predictions). -// The ServingConfig is passed in the search and predict request and together -// with the Catalog.default_branch, generates results. -message ServingConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/ServingConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" - }; - - // Immutable. Fully qualified name - // projects/*/locations/global/catalogs/*/servingConfig/* - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. The human readable serving config display name. Used in Retail - // UI. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // The id of the model to use at serving time. - // Currently only RecommendationModels are supported: - // https://cloud.google.com/retail/recommendations-ai/docs/create-models - // Can be changed but only to a compatible model (e.g. - // others-you-may-like CTR to others-you-may-like CVR). - // - // Required when - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string model_id = 3; - - // How much price ranking we want in serving results. - // Price reranking causes product items with a similar - // recommendation probability to be ordered by price, with the - // highest-priced items first. This setting could result in a decrease in - // click-through and conversion rates. - // Allowed values are: - // - // * 'no-price-reranking' - // * 'low-price-raranking' - // * 'medium-price-reranking' - // * 'high-price-reranking' - // - // If not specified, we choose default based on model type. Default value: - // 'no-price-reranking'. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string price_reranking_level = 4; - - // Facet specifications for faceted search. If empty, no facets are returned. - // The ids refer to the ids of [Control][google.cloud.retail.v2alpha.Control] - // resources with only the Facet control set. These controls are assumed to be - // in the same [Catalog][google.cloud.retail.v2alpha.Catalog] as the - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]. - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string facet_control_ids = 5; - - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; - - // Condition boost specifications. If a product matches multiple conditions - // in the specifications, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 100. - // - // Notice that if both - // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] - // and [SearchRequest.boost_spec] are set, the boost conditions from both - // places are evaluated. If a search request matches multiple boost - // conditions, the final boost score is equal to the sum of the boost scores - // from all matched boost conditions. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string boost_control_ids = 7; - - // Condition filter specifications. If a product matches multiple conditions - // in the specifications, filters from these specifications are all - // applied and combined via the AND operator. Maximum number of - // specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string filter_control_ids = 9; - - // Condition redirect specifications. Only the first triggered redirect action - // is applied, even if multiple apply. Maximum number of specifications is - // 1000. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string redirect_control_ids = 10; - - // Condition synonyms specifications. If multiple syonyms conditions match, - // all matching synonyms control in the list will execute. Order of controls - // in the list will not matter. Maximum number of specifications is - // 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string twoway_synonyms_control_ids = 18; - - // Condition oneway synonyms specifications. If multiple oneway synonyms - // conditions match, all matching oneway synonyms controls in the list will - // execute. Order of controls in the list will not matter. Maximum number of - // specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string oneway_synonyms_control_ids = 12; - - // Condition do not associate specifications. If multiple do not associate - // conditions match, all matching do not associate controls in the list will - // execute. - // - Order does not matter. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string do_not_associate_control_ids = 13; - - // Condition replacement specifications. - // - Applied according to the order in the list. - // - A previously replaced term can not be re-replaced. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string replacement_control_ids = 14; - - // Condition ignore specifications. If multiple ignore - // conditions match, all matching ignore controls in the list will - // execute. - // - Order does not matter. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string ignore_control_ids = 15; - - // How much diversity to use in recommendation model results e.g. - // 'medium-diversity' or 'high-diversity'. Currently supported values: - // - // * 'no-diversity' - // * 'low-diversity' - // * 'medium-diversity' - // * 'high-diversity' - // * 'auto-diversity' - // - // If not specified, we choose default based on recommendation model - // type. Default value: 'no-diversity'. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string diversity_level = 8; - - // Whether to add additional category filters on the 'similar-items' model. - // If not specified, we enable it by default. - // Allowed values are: - // - // * 'no-category-match': No additional filtering of original results from - // the model and the customer's filters. - // * 'relaxed-category-match': Only keep results with categories that match - // at least one item categories in the PredictRequests's context item. - // * If customer also sends filters in the PredictRequest, then the results - // will satisfy both conditions (user given and category match). - // - // Can only be set if - // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string enable_category_filter_level = 16; - - // Required. Immutable. Specifies the solution types that a serving config can - // be associated with. Currently we support setting only one type of solution. - repeated SolutionType solution_types = 19 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto deleted file mode 100644 index 48286797..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/serving_config.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for modifying ServingConfig. -service ServingConfigService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a ServingConfig. - // - // A maximum of 100 - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in - // a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a - // FAILED_PRECONDITION error is returned. - rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" - body: "serving_config" - }; - option (google.api.method_signature) = - "parent,serving_config,serving_config_id"; - } - - // Deletes a ServingConfig. - // - // Returns a NotFound error if the ServingConfig does not exist. - rpc DeleteServingConfig(DeleteServingConfigRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a ServingConfig. - rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - patch: "/v2alpha/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - body: "serving_config" - }; - option (google.api.method_signature) = "serving_config,update_mask"; - } - - // Gets a ServingConfig. - // - // Returns a NotFound error if the ServingConfig does not exist. - rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all ServingConfigs linked to this catalog. - rpc ListServingConfigs(ListServingConfigsRequest) - returns (ListServingConfigsResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" - }; - option (google.api.method_signature) = "parent"; - } - - // Enables a Control on the specified ServingConfig. - // The control is added in the last position of the list of controls - // it belongs to (e.g. if it's a facet spec control it will be applied - // in the last position of servingConfig.facetSpecIds) - // Returns a ALREADY_EXISTS error if the control has already been applied. - // Returns a FAILED_PRECONDITION error if the addition could exceed maximum - // number of control allowed for that type of control. - rpc AddControl(AddControlRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" - body: "*" - }; - option (google.api.method_signature) = "serving_config"; - } - - // Disables a Control on the specified ServingConfig. - // The control is removed from the ServingConfig. - // Returns a NOT_FOUND error if the Control is not enabled for the - // ServingConfig. - rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" - body: "*" - }; - option (google.api.method_signature) = "serving_config"; - } -} - -// Request for CreateServingConfig method. -message CreateServingConfigRequest { - // Required. Full resource name of parent. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The ServingConfig to create. - ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the ServingConfig, which will become the final - // component of the ServingConfig's resource name. - // - // This value should be 4-63 characters, and valid characters - // are /[a-z][0-9]-_/. - string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for UpdateServingConfig method. -message UpdateServingConfigRequest { - // Required. The ServingConfig to update. - ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to update. The - // following are NOT supported: - // - // * [ServingConfig.name][google.cloud.retail.v2alpha.ServingConfig.name] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for DeleteServingConfig method. -message DeleteServingConfigRequest { - // Required. The resource name of the ServingConfig to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; -} - -// Request for GetServingConfig method. -message GetServingConfigRequest { - // Required. The resource name of the ServingConfig to get. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; -} - -// Request for ListServingConfigs method. -message ListServingConfigsRequest { - // Required. The catalog resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Optional. Maximum number of results to return. If unspecified, defaults - // to 100. If a value greater than 100 is provided, at most 100 results are - // returned. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListServingConfigs` call. - // Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for ListServingConfigs method. -message ListServingConfigsResponse { - // All the ServingConfigs for a given catalog. - repeated ServingConfig serving_configs = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} - -// Request for AddControl method. -message AddControlRequest { - // Required. The source ServingConfig resource name . Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; - - // Required. The id of the control to apply. Assumed to be in the same catalog - // as the serving config - if id is not found a NOT_FOUND error is returned. - string control_id = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for RemoveControl method. -message RemoveControlRequest { - // Required. The source ServingConfig resource name . Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; - - // Required. The id of the control to apply. Assumed to be in the same catalog - // as the serving config. - string control_id = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto deleted file mode 100644 index 94f72879..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2alpha/common.proto"; -import "google/cloud/retail/v2alpha/product.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// UserEvent captures all metadata information Retail API needs to know about -// how end users interact with customers' website. -message UserEvent { - // Required. User event type. Allowed values are: - // - // * `add-to-cart`: Products being added to cart. - // * `category-page-view`: Special pages such as sale or promotion pages - // viewed. - // * `detail-page-view`: Products detail page viewed. - // * `home-page-view`: Homepage viewed. - // * `promotion-offered`: Promotion is offered to a user. - // * `promotion-not-offered`: Promotion is not offered to a user. - // * `purchase-complete`: User finishing a purchase. - // * `search`: Product search. - // * `shopping-cart-page-view`: User viewing a shopping cart. - string event_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A unique identifier for tracking visitors. - // - // For example, this could be implemented with an HTTP cookie, which should be - // able to uniquely identify a visitor on a single device. This unique - // identifier should not change if the visitor log in/out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // The field should not contain PII or user-data. We recommend to use Google - // Analystics [Client - // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) - // for this field. - string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // A unique identifier for tracking a visitor session with a length limit of - // 128 bytes. A session is an aggregation of an end user behavior in a time - // span. - // - // A general guideline to populate the sesion_id: - // 1. If user has no activity for 30 min, a new session_id should be assigned. - // 2. The session_id should be unique across users, suggest use uuid or add - // visitor_id as prefix. - string session_id = 21; - - // Only required for - // [UserEventService.ImportUserEvents][google.cloud.retail.v2alpha.UserEventService.ImportUserEvents] - // method. Timestamp of when the user event happened. - google.protobuf.Timestamp event_time = 3; - - // A list of identifiers for the independent experiment groups this user event - // belongs to. This is used to distinguish between user events associated with - // different experiment setups (e.g. using Retail API, using different - // recommendation models). - repeated string experiment_ids = 4; - - // Highly recommended for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. - // This field enables accurate attribution of recommendation model - // performance. - // - // The value must be a valid - // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] - // for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. - // The value must be a valid - // [SearchResponse.attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] - // for user events that are the result of - // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. - // - // This token enables us to accurately attribute page view or purchase back to - // the event and the particular predict response containing this - // clicked/purchased product. If user clicks on product K in the - // recommendation results, pass - // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] - // as a URL parameter to product K's page. When recording events on product - // K's page, log the - // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] - // to this field. - string attribution_token = 5; - - // The main product details related to the event. - // - // This field is required for the following event types: - // - // * `add-to-cart` - // * `detail-page-view` - // * `purchase-complete` - // * `search` - // - // In a `search` event, this field represents the products returned to the end - // user on the current page (the end user may have not finished browsing the - // whole page yet). When a new page is returned to the end user, after - // pagination/filtering/ordering even for the same query, a new `search` event - // with different - // [product_details][google.cloud.retail.v2alpha.UserEvent.product_details] is - // desired. The end user may have not finished browsing the whole page yet. - repeated ProductDetail product_details = 6; - - // The main auto-completion details related to the event. - // - // This field should be set for `search` event when autocomplete function is - // enabled and the user clicks a suggestion for search. - CompletionDetail completion_detail = 22; - - // Extra user event features to include in the recommendation model. - // - // If you provide custom attributes for ingested user events, also include - // them in the user events that you associate with prediction requests. Custom - // attribute formatting must be consistent between imported events and events - // provided with prediction requests. This lets the Retail API use - // those custom attributes when training models and serving predictions, which - // helps improve recommendation quality. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * The key must be a UTF-8 encoded string with a length limit of 5,000 - // characters. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 256 characters. - // * For number attributes, at most 400 values are allowed. - // - // For product recommendations, an example of extra user information is - // traffic_channel, which is how a user arrives at the site. Users can arrive - // at the site by coming to the site directly, coming through Google - // search, or in other ways. - map attributes = 7; - - // The ID or name of the associated shopping cart. This ID is used - // to associate multiple items added or present in the cart before purchase. - // - // This can only be set for `add-to-cart`, `purchase-complete`, or - // `shopping-cart-page-view` events. - string cart_id = 8; - - // A transaction represents the entire purchase transaction. - // - // Required for `purchase-complete` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - PurchaseTransaction purchase_transaction = 9; - - // The user's search query. - // - // See [SearchRequest.query][google.cloud.retail.v2alpha.SearchRequest.query] - // for definition. - // - // The value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // At least one of - // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - string search_query = 10; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. - // - // See - // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string filter = 16; - - // The order in which products are returned. - // - // See - // [SearchRequest.order_by][google.cloud.retail.v2alpha.SearchRequest.order_by] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string order_by = 17; - - // An integer that specifies the current offset for pagination (the 0-indexed - // starting location, amongst the products deemed by the API as relevant). - // - // See - // [SearchRequest.offset][google.cloud.retail.v2alpha.SearchRequest.offset] - // for definition. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - int32 offset = 18; - - // The categories associated with a category page. - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - // - // Required for `category-page-view` events. At least one of - // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated string page_categories = 11; - - // User information. - UserInfo user_info = 12; - - // Complete URL (window.location.href) of the user's current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. Maximum length 5,000 - // characters. - string uri = 13; - - // The referrer URL of the current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string referrer_uri = 14; - - // A unique ID of a web page view. - // - // This should be kept the same for all user events triggered from the same - // pageview. For example, an item detail page view could trigger multiple - // events as the user is browsing the page. The `pageViewId` property should - // be kept the same for all these events so that they can be grouped together - // properly. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string page_view_id = 15; -} - -// Detailed product information associated with a user event. -message ProductDetail { - // Required. [Product][google.cloud.retail.v2alpha.Product] information. - // - // Required field(s): - // - // * [Product.id][google.cloud.retail.v2alpha.Product.id] - // - // Optional override field(s): - // - // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] - // - // If any supported optional fields are provided, we will treat them as a full - // override when looking up product information from the catalog. Thus, it is - // important to ensure that the overriding fields are accurate and - // complete. - // - // All other product fields are ignored and instead populated via catalog - // lookup after event ingestion. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Quantity of the product associated with the user event. - // - // For example, this field will be 2 if two products are added to the shopping - // cart for `purchase-complete` event. Required for `add-to-cart` and - // `purchase-complete` event types. - google.protobuf.Int32Value quantity = 2; -} - -// Detailed completion information including completion attribution token and -// clicked completion info. -message CompletionDetail { - // Completion attribution token in - // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2alpha.CompleteQueryResponse.attribution_token]. - string completion_attribution_token = 1; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion]. - string selected_suggestion = 2; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion] - // position, starting from 0. - int32 selected_position = 3; -} - -// A transaction represents the entire purchase transaction. -message PurchaseTransaction { - // The transaction ID with a length limit of 128 characters. - string id = 1; - - // Required. Total non-zero revenue or grand total associated with the - // transaction. This value include shipping, tax, or other adjustments to - // total revenue that you want to include as part of your revenue - // calculations. - float revenue = 2 [(google.api.field_behavior) = REQUIRED]; - - // All the taxes associated with the transaction. - float tax = 3; - - // All the costs associated with the products. These can be manufacturing - // costs, shipping expenses not borne by the end user, or any other costs, - // such that: - // - // * Profit = - // [revenue][google.cloud.retail.v2alpha.PurchaseTransaction.revenue] - - // [tax][google.cloud.retail.v2alpha.PurchaseTransaction.tax] - - // [cost][google.cloud.retail.v2alpha.PurchaseTransaction.cost] - float cost = 4; - - // Required. Currency code. Use three-character ISO-4217 code. - string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto b/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto deleted file mode 100644 index af97dad9..00000000 --- a/owl-bot-staging/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/httpbody.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2alpha/import_config.proto"; -import "google/cloud/retail/v2alpha/purge_config.proto"; -import "google/cloud/retail/v2alpha/user_event.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventServiceProto"; -option java_package = "com.google.cloud.retail.v2alpha"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; -option ruby_package = "Google::Cloud::Retail::V2alpha"; - -// Service for ingesting end user actions on the customer website. -service UserEventService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Writes a single user event. - rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" - body: "user_event" - }; - } - - // Writes a single user event from the browser. This uses a GET request to - // due to browser restriction of POST-ing to a 3rd party domain. - // - // This method is used only by the Retail API JavaScript pixel and Google Tag - // Manager. Users should not call this method directly. - rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" - }; - } - - // Deletes permanently all user events specified by the filter provided. - // Depending on the number of events specified by the filter, this operation - // could take hours or days to complete. To test a filter, use the list - // command first. - rpc PurgeUserEvents(PurgeUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.PurgeUserEventsResponse" - metadata_type: "google.cloud.retail.v2alpha.PurgeMetadata" - }; - } - - // Bulk import of User events. Request processing might be - // synchronous. Events that already exist are skipped. - // Use this method for backfilling historical user events. - // - // Operation.response is of type ImportResponse. Note that it is - // possible for a subset of the items to be successfully inserted. - // Operation.metadata is of type ImportMetadata. - rpc ImportUserEvents(ImportUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.ImportUserEventsResponse" - metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" - }; - } - - // Starts a user event rejoin operation with latest product catalog. Events - // will not be annotated with detailed product information if product is - // missing from the catalog at the time the user event is ingested, and these - // events are stored as unjoined events with a limited usage on training and - // serving. This method can be used to start a join operation on specified - // events with latest version of product catalog. It can also be used to - // correct events joined with the wrong product catalog. A rejoin operation - // can take hours or days to complete. - rpc RejoinUserEvents(RejoinUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "RejoinUserEventsResponse" - metadata_type: "RejoinUserEventsMetadata" - }; - } -} - -// Request message for WriteUserEvent method. -message WriteUserEventRequest { - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User event to write. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // Required. The parent catalog name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. URL encoded UserEvent proto with a length limit of 2,000,000 - // characters. - string user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // The URL including cgi-parameters but excluding the hash fragment with a - // length limit of 5,000 characters. This is often more useful than the - // referer URL, because many browsers only send the domain for 3rd party - // requests. - string uri = 3; - - // The event timestamp in milliseconds. This prevents browser caching of - // otherwise identical get requests. The name is abbreviated to reduce the - // payload bytes. - int64 ets = 4; -} - -// Request message for RejoinUserEvents method. -message RejoinUserEventsRequest { - // The scope of user events to be rejoined with the latest product catalog. - // If the rejoining aims at reducing number of unjoined events, set - // UserEventRejoinScope to UNJOINED_EVENTS. - // If the rejoining aims at correcting product catalog information in joined - // events, set UserEventRejoinScope to JOINED_EVENTS. - // If all events needs to be rejoined, set UserEventRejoinScope to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. - enum UserEventRejoinScope { - // Rejoin all events with the latest product catalog, including both joined - // events and unjoined events. - USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; - - // Only rejoin joined events with the latest product catalog. - JOINED_EVENTS = 1; - - // Only rejoin unjoined events with the latest product catalog. - UNJOINED_EVENTS = 2; - } - - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The type of the user event rejoin to define the scope and range of the user - // events to be rejoined with the latest product catalog. Defaults to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - // invalid integer value. - UserEventRejoinScope user_event_rejoin_scope = 2; -} - -// Response message for RejoinUserEvents method. -message RejoinUserEventsResponse { - // Number of user events that were joined with latest product catalog. - int64 rejoined_user_events_count = 1; -} - -// Metadata for RejoinUserEvents method. -message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js deleted file mode 100644 index 0a46b0bb..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(attributesConfig, catalogAttribute) { - // [START retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The - * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to add. - */ - // const catalogAttribute = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callAddCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - catalogAttribute, - }; - - // Run request - const response = await retailClient.addCatalogAttribute(request); - console.log(response); - } - - callAddCatalogAttribute(); - // [END retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js deleted file mode 100644 index 8fe314bf..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_CatalogService_GetAttributesConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const name = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetAttributesConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getAttributesConfig(request); - console.log(response); - } - - callGetAttributesConfig(); - // [END retail_v2alpha_generated_CatalogService_GetAttributesConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js deleted file mode 100644 index b189f66e..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_CatalogService_GetCompletionConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full CompletionConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - */ - // const name = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetCompletionConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getCompletionConfig(request); - console.log(response); - } - - callGetCompletionConfig(); - // [END retail_v2alpha_generated_CatalogService_GetCompletionConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js deleted file mode 100644 index 075a2b10..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2alpha_generated_CatalogService_GetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.getDefaultBranch(request); - console.log(response); - } - - callGetDefaultBranch(); - // [END retail_v2alpha_generated_CatalogService_GetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js deleted file mode 100644 index 2bed2f3f..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2alpha_generated_CatalogService_ListCatalogs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The account resource name with an associated location. - * If the caller does not have permission to list - * Catalog google.cloud.retail.v2alpha.Catalog s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Catalog google.cloud.retail.v2alpha.Catalog s to - * return. If unspecified, defaults to 50. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListCatalogsResponse.next_page_token google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token, - * received from a previous - * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callListCatalogs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listCatalogsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCatalogs(); - // [END retail_v2alpha_generated_CatalogService_ListCatalogs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js deleted file mode 100644 index 81358df9..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(attributesConfig, key) { - // [START retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The attribute name key of the - * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to remove. - */ - // const key = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callRemoveCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - key, - }; - - // Run request - const response = await retailClient.removeCatalogAttribute(request); - console.log(response); - } - - callRemoveCatalogAttribute(); - // [END retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js deleted file mode 100644 index 2fdfc582..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.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(attributesConfig, catalogAttribute) { - // [START retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The updated - * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute. - */ - // const catalogAttribute = {} - /** - * Indicates which fields in the provided - * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to update. - * The following are NOT supported: - * * CatalogAttribute.key google.cloud.retail.v2alpha.CatalogAttribute.key - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callReplaceCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - catalogAttribute, - }; - - // Run request - const response = await retailClient.replaceCatalogAttribute(request); - console.log(response); - } - - callReplaceCatalogAttribute(); - // [END retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js deleted file mode 100644 index 7fce54ef..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2alpha_generated_CatalogService_SetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * The final component of the resource name of a branch. - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * If there are no sufficient active products in the targeted branch and - * force google.cloud.retail.v2alpha.SetDefaultBranchRequest.force is not - * set, a FAILED_PRECONDITION error is returned. - */ - // const branchId = 'abc123' - /** - * Some note on this request, this can be retrieved by - * CatalogService.GetDefaultBranch google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch - * before next valid default branch set occurs. - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const note = 'abc123' - /** - * If set to true, it permits switching to a branch with - * branch_id google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id - * even if it has no sufficient active products. - */ - // const force = true - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callSetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.setDefaultBranch(request); - console.log(response); - } - - callSetDefaultBranch(); - // [END retail_v2alpha_generated_CatalogService_SetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js deleted file mode 100644 index bf5828a2..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.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(attributesConfig) { - // [START retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The - * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. - */ - // const attributesConfig = {} - /** - * Indicates which fields in the provided - * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. - * The following is the only supported field: - * * AttributesConfig.catalog_attributes google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateAttributesConfig() { - // Construct request - const request = { - attributesConfig, - }; - - // Run request - const response = await retailClient.updateAttributesConfig(request); - console.log(response); - } - - callUpdateAttributesConfig(); - // [END retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js deleted file mode 100644 index 81ee698f..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.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(catalog) { - // [START retail_v2alpha_generated_CatalogService_UpdateCatalog_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Catalog google.cloud.retail.v2alpha.Catalog to update. - * If the caller does not have permission to update the - * Catalog google.cloud.retail.v2alpha.Catalog, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * If the Catalog google.cloud.retail.v2alpha.Catalog to update does not - * exist, a NOT_FOUND error is returned. - */ - // const catalog = {} - /** - * Indicates which fields in the provided - * Catalog google.cloud.retail.v2alpha.Catalog to update. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCatalog() { - // Construct request - const request = { - catalog, - }; - - // Run request - const response = await retailClient.updateCatalog(request); - console.log(response); - } - - callUpdateCatalog(); - // [END retail_v2alpha_generated_CatalogService_UpdateCatalog_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js deleted file mode 100644 index 62e6eea3..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.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(completionConfig) { - // [START retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The - * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. - * If the caller does not have permission to update the - * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig, then a - * PERMISSION_DENIED error is returned. - * If the CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to - * update does not exist, a NOT_FOUND error is returned. - */ - // const completionConfig = {} - /** - * Indicates which fields in the provided - * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. - * The following are the only supported fields: - * * CompletionConfig.matching_order google.cloud.retail.v2alpha.CompletionConfig.matching_order - * * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions - * * CompletionConfig.min_prefix_length google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length - * * CompletionConfig.auto_learning google.cloud.retail.v2alpha.CompletionConfig.auto_learning - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCompletionConfig() { - // Construct request - const request = { - completionConfig, - }; - - // Run request - const response = await retailClient.updateCompletionConfig(request); - console.log(response); - } - - callUpdateCompletionConfig(); - // [END retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js deleted file mode 100644 index 6f768b76..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(catalog, query) { - // [START retail_v2alpha_generated_CompletionService_CompleteQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Catalog for which the completion is performed. - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * Required. The query used to generate suggestions. - * The maximum number of allowed characters is 255. - */ - // const query = 'abc123' - /** - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see Tags for - * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - */ - // const languageCodes = 'abc123' - /** - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * Supported formats: - * * `UNKNOWN_DEVICE_TYPE` - * * `DESKTOP` - * * `MOBILE` - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - */ - // const deviceType = 'abc123' - /** - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * CompletionService.ImportCompletionData google.cloud.retail.v2alpha.CompletionService.ImportCompletionData. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * Current supported values: - * * user-data - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - */ - // const dataset = 'abc123' - /** - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value - * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions. - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - */ - // const maxSuggestions = 1234 - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callCompleteQuery() { - // Construct request - const request = { - catalog, - query, - }; - - // Run request - const response = await retailClient.completeQuery(request); - console.log(response); - } - - callCompleteQuery(); - // [END retail_v2alpha_generated_CompletionService_CompleteQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js deleted file mode 100644 index b54422e5..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.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, inputConfig) { - // [START retail_v2alpha_generated_CompletionService_ImportCompletionData_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog which the suggestions dataset belongs to. - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callImportCompletionData() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importCompletionData(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportCompletionData(); - // [END retail_v2alpha_generated_CompletionService_ImportCompletionData_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.js deleted file mode 100644 index bacd422a..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.create_control.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, control, controlId) { - // [START retail_v2alpha_generated_ControlService_CreateControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of parent catalog. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Required. The Control to create. - */ - // const control = {} - /** - * Required. The ID to use for the Control, which will become the final - * component of the Control's resource name. - * This value should be 4-63 characters, and valid characters - * are /[a-z][0-9]-_/. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callCreateControl() { - // Construct request - const request = { - parent, - control, - controlId, - }; - - // Run request - const response = await retailClient.createControl(request); - console.log(response); - } - - callCreateControl(); - // [END retail_v2alpha_generated_ControlService_CreateControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js deleted file mode 100644 index 6afa1e03..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.delete_control.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ControlService_DeleteControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callDeleteControl() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteControl(request); - console.log(response); - } - - callDeleteControl(); - // [END retail_v2alpha_generated_ControlService_DeleteControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js deleted file mode 100644 index a0c4c927..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.get_control.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ControlService_GetControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callGetControl() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getControl(request); - console.log(response); - } - - callGetControl(); - // [END retail_v2alpha_generated_ControlService_GetControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js deleted file mode 100644 index c09815fd..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.list_controls.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2alpha_generated_ControlService_ListControls_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - /** - * Optional. A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2alpha.ListControlsRequest.filter is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - */ - // const filter = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callListControls() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listControlsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListControls(); - // [END retail_v2alpha_generated_ControlService_ListControls_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js deleted file mode 100644 index 7f0e4c67..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/control_service.update_control.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(control) { - // [START retail_v2alpha_generated_ControlService_UpdateControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Control to update. - */ - // const control = {} - /** - * Indicates which fields in the provided - * Control google.cloud.retail.v2alpha.Control to update. The following are - * NOT supported: - * * Control.name google.cloud.retail.v2alpha.Control.name - * If not set or empty, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callUpdateControl() { - // Construct request - const request = { - control, - }; - - // Run request - const response = await retailClient.updateControl(request); - console.log(response); - } - - callUpdateControl(); - // [END retail_v2alpha_generated_ControlService_UpdateControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js deleted file mode 100644 index f49c45f1..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/prediction_service.predict.js +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, userEvent) { - // [START retail_v2alpha_generated_PredictionService_Predict_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see Managing - * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - */ - // const placement = 'abc123' - /** - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - */ - // const userEvent = {} - /** - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - */ - // const pageSize = 1234 - /** - * The previous PredictResponse.next_page_token. - */ - // const pageToken = 'abc123' - /** - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * Examples: - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - */ - // const filter = 'abc123' - /** - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - */ - // const validateOnly = true - /** - * Additional domain specific parameters for the predictions. - * Allowed values: - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - */ - // const params = 1234 - /** - * The labels applied to a resource must meet the following requirements: - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * See Google Cloud - * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - */ - // const labels = 1234 - - // Imports the Retail library - const {PredictionServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new PredictionServiceClient(); - - async function callPredict() { - // Construct request - const request = { - placement, - userEvent, - }; - - // Run request - const response = await retailClient.predict(request); - console.log(response); - } - - callPredict(); - // [END retail_v2alpha_generated_PredictionService_Predict_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js deleted file mode 100644 index c15b5aa0..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type, such - * as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type. - * Duplicate IDs will be automatically ignored. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * If the total number of place IDs exceeds 2000 for this - * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type after - * adding, then the update will be rejected. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * Product google.cloud.retail.v2alpha.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddFulfillmentPlaces(); - // [END retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js deleted file mode 100644 index 1a0bcb74..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, localInventories) { - // [START retail_v2alpha_generated_ProductService_AddLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - */ - // const localInventories = 1234 - /** - * Indicates which inventory fields in the provided list of - * LocalInventory google.cloud.retail.v2alpha.LocalInventory to update. The - * field is updated to the provided value. - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const addMask = {} - /** - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, the local inventory will still be processed and retained for at - * most 1 day and processed once the - * Product google.cloud.retail.v2alpha.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddLocalInventories() { - // Construct request - const request = { - product, - localInventories, - }; - - // Run request - const [operation] = await retailClient.addLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddLocalInventories(); - // [END retail_v2alpha_generated_ProductService_AddLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js deleted file mode 100644 index d452aae4..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.create_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, product, productId) { - // [START retail_v2alpha_generated_ProductService_CreateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - */ - // const parent = 'abc123' - /** - * Required. The Product google.cloud.retail.v2alpha.Product to create. - */ - // const product = {} - /** - * Required. The ID to use for the - * Product google.cloud.retail.v2alpha.Product, which will become the final - * component of the Product.name google.cloud.retail.v2alpha.Product.name. - * If the caller does not have permission to create the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * This field must be unique among all - * Product google.cloud.retail.v2alpha.Product s with the same - * parent google.cloud.retail.v2alpha.CreateProductRequest.parent. - * Otherwise, an ALREADY_EXISTS error is returned. - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const productId = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - productId, - }; - - // Run request - const response = await retailClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END retail_v2alpha_generated_ProductService_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_product.js deleted file mode 100644 index 7470b33d..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.delete_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(name) { - // [START retail_v2alpha_generated_ProductService_DeleteProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to delete the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2alpha.Product to delete does not - * exist, a NOT_FOUND error is returned. - * The Product google.cloud.retail.v2alpha.Product to delete can neither be - * a - * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION - * Product google.cloud.retail.v2alpha.Product member nor a - * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY - * Product google.cloud.retail.v2alpha.Product with more than one - * variants google.cloud.retail.v2alpha.Product.Type.VARIANT. Otherwise, an - * INVALID_ARGUMENT error is returned. - * All inventory information for the named - * Product google.cloud.retail.v2alpha.Product will be deleted. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END retail_v2alpha_generated_ProductService_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js deleted file mode 100644 index 52340240..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.get_product.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ProductService_GetProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * If the requested Product google.cloud.retail.v2alpha.Product does not - * exist, a NOT_FOUND error is returned. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END retail_v2alpha_generated_ProductService_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js deleted file mode 100644 index 26a70a51..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.import_products.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2alpha_generated_ProductService_ImportProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. - */ - // const errorsConfig = {} - /** - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - */ - // const updateMask = {} - /** - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * ReconciliationMode.INCREMENTAL google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL. - */ - // const reconciliationMode = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * Only supported when - * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode - * is set to `FULL`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callImportProducts() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProducts(); - // [END retail_v2alpha_generated_ProductService_ImportProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js deleted file mode 100644 index a9e1ed2f..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.list_products.js +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2alpha_generated_ProductService_ListProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * If the caller does not have permission to list - * Product google.cloud.retail.v2alpha.Product s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Product google.cloud.retail.v2alpha.Product s to - * return. If unspecified, defaults to 100. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT error is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListProductsResponse.next_page_token google.cloud.retail.v2alpha.ListProductsResponse.next_page_token, - * received from a previous - * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2alpha.ListProductsRequest.filter is unset. - * * List - * Product.Type.VARIANT google.cloud.retail.v2alpha.Product.Type.VARIANT - * Product google.cloud.retail.v2alpha.Product s sharing the same - * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY - * Product google.cloud.retail.v2alpha.Product. For example: - * `primary_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2alpha.Product s bundled in a - * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION - * Product google.cloud.retail.v2alpha.Product. - * For example: - * `collection_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2alpha.Product s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * If the specified - * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY - * Product google.cloud.retail.v2alpha.Product or - * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION - * Product google.cloud.retail.v2alpha.Product does not exist, a NOT_FOUND - * error is returned. - */ - // const filter = 'abc123' - /** - * The fields of Product google.cloud.retail.v2alpha.Product to return in - * the responses. If not set or empty, the following fields are returned: - * * Product.name google.cloud.retail.v2alpha.Product.name - * * Product.id google.cloud.retail.v2alpha.Product.id - * * Product.title google.cloud.retail.v2alpha.Product.title - * * Product.uri google.cloud.retail.v2alpha.Product.uri - * * Product.images google.cloud.retail.v2alpha.Product.images - * * Product.price_info google.cloud.retail.v2alpha.Product.price_info - * * Product.brands google.cloud.retail.v2alpha.Product.brands - * If "*" is provided, all fields are returned. - * Product.name google.cloud.retail.v2alpha.Product.name is always returned - * no matter what mask is set. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const readMask = {} - /** - * If true and - * page_token google.cloud.retail.v2alpha.ListProductsRequest.page_token is - * empty, - * ListProductsResponse.total_size google.cloud.retail.v2alpha.ListProductsResponse.total_size - * is set to the total count of matched items irrespective of pagination. - * Notice that setting this field to true affects the performance. - */ - // const requireTotalSize = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END retail_v2alpha_generated_ProductService_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js deleted file mode 100644 index 55d09aef..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.purge_products.js +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, filter) { - // [START retail_v2alpha_generated_ProductService_PurgeProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the branch under which the products are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` - */ - // const parent = 'abc123' - /** - * Required. The filter string to specify the products to be deleted with a - * length limit of 5,000 characters. - * Empty string filter is not allowed. "*" implies delete all items in a - * branch. - * The eligible fields for filtering are: - * * `availability`: Double quoted - * Product.availability google.cloud.retail.v2alpha.Product.availability - * string. - * * `create_time` : in ISO 8601 "zulu" format. - * Supported syntax: - * * Comparators (">", "<", ">=", "<=", "="). - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" - * * availability = "IN_STOCK" - * * Conjunctions ("AND") - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" - * * Disjunctions ("OR") - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" - * * Can support nested queries. - * Examples: - * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") - * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") - * * Filter Limits: - * * Filter should not contain more than 6 conditions. - * * Max nesting depth should not exceed 2 levels. - * Examples queries: - * * Delete back order products created before a timestamp. - * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" - */ - // const filter = 'abc123' - /** - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any products. - */ - // const force = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await retailClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END retail_v2alpha_generated_ProductService_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js deleted file mode 100644 index 9543acde..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type, - * such as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * Product google.cloud.retail.v2alpha.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveFulfillmentPlaces(); - // [END retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js deleted file mode 100644 index 903fe738..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, placeIds) { - // [START retail_v2alpha_generated_ProductService_RemoveLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2alpha.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - */ - // const placeIds = 'abc123' - /** - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * Product google.cloud.retail.v2alpha.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveLocalInventories() { - // Construct request - const request = { - product, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveLocalInventories(); - // [END retail_v2alpha_generated_ProductService_RemoveLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js deleted file mode 100644 index 00d04376..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js +++ /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 -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(inventory) { - // [START retail_v2alpha_generated_ProductService_SetInventory_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The inventory information to update. The allowable fields to - * update are: - * * Product.price_info google.cloud.retail.v2alpha.Product.price_info - * * Product.availability google.cloud.retail.v2alpha.Product.availability - * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info - * The updated inventory fields must be specified in - * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask. - * If SetInventoryRequest.inventory.name is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2alpha.Product named in - * Product.name google.cloud.retail.v2alpha.Product.name, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2alpha.Product to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * If the Product google.cloud.retail.v2alpha.Product to update has - * existing inventory information, the provided inventory information will be - * merged while respecting the last update time for each inventory field, - * using the provided or default value for - * SetInventoryRequest.set_time google.cloud.retail.v2alpha.SetInventoryRequest.set_time. - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in SetInventoryRequest.inventory.fulfillment_info - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types to clear in - * SetInventoryRequest.inventory.fulfillment_info - * * Checks that only the desired fulfillment info types have empty - * SetInventoryRequest.inventory.fulfillment_info.place_ids - * The last update time is recorded for the following inventory fields: - * * Product.price_info google.cloud.retail.v2alpha.Product.price_info - * * Product.availability google.cloud.retail.v2alpha.Product.availability - * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info - * If a full overwrite of inventory information while ignoring timestamps is - * needed, UpdateProduct should be invoked instead. - */ - // const inventory = {} - /** - * Indicates which inventory fields in the provided - * Product google.cloud.retail.v2alpha.Product to update. - * At least one field must be provided. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const setMask = {} - /** - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - */ - // const setTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product with - * name Product.name google.cloud.retail.v2alpha.Product.name is not found, - * the inventory update will still be processed and retained for at most 1 day - * until the Product google.cloud.retail.v2alpha.Product is created. If set - * to false, a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2alpha.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callSetInventory() { - // Construct request - const request = { - inventory, - }; - - // Run request - const [operation] = await retailClient.setInventory(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInventory(); - // [END retail_v2alpha_generated_ProductService_SetInventory_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js deleted file mode 100644 index db9b00e4..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/product_service.update_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START retail_v2alpha_generated_ProductService_UpdateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The product to update/create. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2alpha.Product, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2alpha.Product to update does not - * exist and - * allow_missing google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing - * is not set, a NOT_FOUND error is returned. - */ - // const product = {} - /** - * Indicates which fields in the provided - * Product google.cloud.retail.v2alpha.Product to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - /** - * If set to true, and the Product google.cloud.retail.v2alpha.Product is - * not found, a new Product google.cloud.retail.v2alpha.Product will be - * created. In this situation, `update_mask` is ignored. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await retailClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END retail_v2alpha_generated_ProductService_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js deleted file mode 100644 index 9c4c8b0d..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/search_service.search.js +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, visitorId) { - // [START retail_v2alpha_generated_SearchService_Search_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - */ - // const placement = 'abc123' - /** - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - */ - // const branch = 'abc123' - /** - * Raw search query. - */ - // const query = 'abc123' - /** - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * This should be the same identifier as - * UserEvent.visitor_id google.cloud.retail.v2alpha.UserEvent.visitor_id. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * User information. - */ - // const userInfo = {} - /** - * Maximum number of Product google.cloud.retail.v2alpha.Product s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 120. Values above 120 will be coerced to 120. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * SearchResponse.next_page_token google.cloud.retail.v2alpha.SearchResponse.next_page_token, - * received from a previous - * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * Product google.cloud.retail.v2alpha.Product s deemed by the API as - * relevant) in search results. This field is only considered if - * page_token google.cloud.retail.v2alpha.SearchRequest.page_token is - * unset. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const offset = 1234 - /** - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const filter = 'abc123' - /** - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * SearchRequest.canonical_filter google.cloud.retail.v2alpha.SearchRequest.canonical_filter - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * See - * SearchRequest.filter google.cloud.retail.v2alpha.SearchRequest.filter - * for more details about filter syntax. - */ - // const canonicalFilter = 'abc123' - /** - * The order in which products are returned. Products can be ordered by - * a field in an Product google.cloud.retail.v2alpha.Product object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#order). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const orderBy = 'abc123' - /** - * Facet specifications for faceted search. If empty, no facets are returned. - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - */ - // const facetSpecs = 1234 - /** - * Boost specification to boost certain products. See more details at this - * user guide (https://cloud.google.com/retail/docs/boosting). - * Notice that if both - * ServingConfig.boost_control_ids google.cloud.retail.v2alpha.ServingConfig.boost_control_ids - * and SearchRequest.boost_spec are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - */ - // const boostSpec = {} - /** - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this user - * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). - */ - // const queryExpansionSpec = {} - /** - * The relevance threshold of the search results. - * Defaults to - * RelevanceThreshold.HIGH google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH, - * which means only the most relevant results are shown, and the least number - * of results are returned. See more details at this user - * guide (https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - */ - // const relevanceThreshold = {} - /** - * The keys to fetch and rollup the matching - * variant google.cloud.retail.v2alpha.Product.Type.VARIANT - * Product google.cloud.retail.v2alpha.Product s attributes, - * FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo or - * LocalInventory google.cloud.retail.v2alpha.LocalInventory s attributes. - * The attributes from all the matching - * variant google.cloud.retail.v2alpha.Product.Type.VARIANT - * Product google.cloud.retail.v2alpha.Product s or - * LocalInventory google.cloud.retail.v2alpha.LocalInventory s are merged - * and de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * For FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * Supported keys are: - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * Product.inventories.attributes map. - * * attributes.key, where key is any key in the - * Product.attributes google.cloud.retail.v2alpha.Product.attributes map. - * * pickupInStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "pickup-in-store". - * * shipToStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-1". - * * customFulfillment2.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-2". - * * customFulfillment3.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-3". - * * customFulfillment4.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-4". - * * customFulfillment5.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids - * for - * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type - * "custom-type-5". - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - */ - // const variantRollupKeys = 'abc123' - /** - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * UserEvent.page_categories google.cloud.retail.v2alpha.UserEvent.page_categories; - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : "Sales > 2017 Black Friday Deals". - */ - // const pageCategories = 'abc123' - /** - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - */ - // const searchMode = {} - /** - * The specification for personalization. - */ - // const personalizationSpec = {} - - // Imports the Retail library - const {SearchServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new SearchServiceClient(); - - async function callSearch() { - // Construct request - const request = { - placement, - visitorId, - }; - - // Run request - const iterable = await retailClient.searchAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearch(); - // [END retail_v2alpha_generated_SearchService_Search_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js deleted file mode 100644 index 5145a2cb..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig, controlId) { - // [START retail_v2alpha_generated_ServingConfigService_AddControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const servingConfig = 'abc123' - /** - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config - if id is not found a NOT_FOUND error is returned. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callAddControl() { - // Construct request - const request = { - servingConfig, - controlId, - }; - - // Run request - const response = await retailClient.addControl(request); - console.log(response); - } - - callAddControl(); - // [END retail_v2alpha_generated_ServingConfigService_AddControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js deleted file mode 100644 index 5a4982b7..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.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, servingConfig, servingConfigId) { - // [START retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of parent. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Required. The ServingConfig to create. - */ - // const servingConfig = {} - /** - * Required. The ID to use for the ServingConfig, which will become the final - * component of the ServingConfig's resource name. - * This value should be 4-63 characters, and valid characters - * are /[a-z][0-9]-_/. - */ - // const servingConfigId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callCreateServingConfig() { - // Construct request - const request = { - parent, - servingConfig, - servingConfigId, - }; - - // Run request - const response = await retailClient.createServingConfig(request); - console.log(response); - } - - callCreateServingConfig(); - // [END retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js deleted file mode 100644 index 4ca230b4..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the ServingConfig to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callDeleteServingConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteServingConfig(request); - console.log(response); - } - - callDeleteServingConfig(); - // [END retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js deleted file mode 100644 index b88b3af3..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the ServingConfig to get. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callGetServingConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getServingConfig(request); - console.log(response); - } - - callGetServingConfig(); - // [END retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js deleted file mode 100644 index b79bfca1..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.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 retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callListServingConfigs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listServingConfigsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServingConfigs(); - // [END retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js deleted file mode 100644 index c1ea7176..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig, controlId) { - // [START retail_v2alpha_generated_ServingConfigService_RemoveControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const servingConfig = 'abc123' - /** - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callRemoveControl() { - // Construct request - const request = { - servingConfig, - controlId, - }; - - // Run request - const response = await retailClient.removeControl(request); - console.log(response); - } - - callRemoveControl(); - // [END retail_v2alpha_generated_ServingConfigService_RemoveControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js deleted file mode 100644 index 7f236fba..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig) { - // [START retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ServingConfig to update. - */ - // const servingConfig = {} - /** - * Indicates which fields in the provided - * ServingConfig google.cloud.retail.v2alpha.ServingConfig to update. The - * following are NOT supported: - * * ServingConfig.name google.cloud.retail.v2alpha.ServingConfig.name - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callUpdateServingConfig() { - // Construct request - const request = { - servingConfig, - }; - - // Run request - const response = await retailClient.updateServingConfig(request); - console.log(response); - } - - callUpdateServingConfig(); - // [END retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json b/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json deleted file mode 100644 index 1072ee94..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json +++ /dev/null @@ -1,2187 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-retail", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.retail.v2alpha", - "version": "v2alpha" - } - ] - }, - "snippets": [ - { - "regionTag": "retail_v2alpha_generated_CatalogService_ListCatalogs_async", - "title": "CatalogService listCatalogs Sample", - "origin": "API_DEFINITION", - "description": " Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated with the project.", - "canonical": true, - "file": "catalog_service.list_catalogs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ListCatalogsResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCatalog_async", - "title": "CatalogService updateCatalog Sample", - "origin": "API_DEFINITION", - "description": " Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s.", - "canonical": true, - "file": "catalog_service.update_catalog.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": ".google.cloud.retail.v2alpha.Catalog" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Catalog", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_SetDefaultBranch_async", - "title": "CatalogService setDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", - "canonical": true, - "file": "catalog_service.set_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "branch_id", - "type": "TYPE_STRING" - }, - { - "name": "note", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_GetDefaultBranch_async", - "title": "CatalogService getDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] method under a specified parent catalog.", - "canonical": true, - "file": "catalog_service.get_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.GetDefaultBranchResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_GetCompletionConfig_async", - "title": "CatalogService getCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig].", - "canonical": true, - "file": "catalog_service.get_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async", - "title": "CatalogService updateCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s.", - "canonical": true, - "file": "catalog_service.update_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", - "async": true, - "parameters": [ - { - "name": "completion_config", - "type": ".google.cloud.retail.v2alpha.CompletionConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_GetAttributesConfig_async", - "title": "CatalogService getAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig].", - "canonical": true, - "file": "catalog_service.get_attributes_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async", - "title": "CatalogService updateAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", - "canonical": true, - "file": "catalog_service.update_attributes_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": ".google.cloud.retail.v2alpha.AttributesConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async", - "title": "CatalogService addCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", - "canonical": true, - "file": "catalog_service.add_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2alpha.CatalogAttribute" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async", - "title": "CatalogService removeCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "catalog_service.remove_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "key", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async", - "title": "CatalogService replaceCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "catalog_service.replace_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2alpha.CatalogAttribute" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2alpha.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CompletionService_CompleteQuery_async", - "title": "CatalogService completeQuery Sample", - "origin": "API_DEFINITION", - "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 109, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "language_codes", - "type": "TYPE_STRING[]" - }, - { - "name": "device_type", - "type": "TYPE_STRING" - }, - { - "name": "dataset", - "type": "TYPE_STRING" - }, - { - "name": "max_suggestions", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.retail.v2alpha.CompleteQueryResponse", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" - }, - "method": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2alpha.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_CompletionService_ImportCompletionData_async", - "title": "CatalogService importCompletionData Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.import_completion_data.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2alpha.CompletionDataInputConfig" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" - }, - "method": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2alpha.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_CreateControl_async", - "title": "CatalogService createControl Sample", - "origin": "API_DEFINITION", - "description": " Creates a Control. If the [Control][google.cloud.retail.v2alpha.Control] to create already exists, an ALREADY_EXISTS error is returned.", - "canonical": true, - "file": "control_service.create_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "control", - "type": ".google.cloud.retail.v2alpha.Control" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_DeleteControl_async", - "title": "CatalogService deleteControl Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Control. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.delete_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_UpdateControl_async", - "title": "CatalogService updateControl Sample", - "origin": "API_DEFINITION", - "description": " Updates a Control. [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.update_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", - "async": true, - "parameters": [ - { - "name": "control", - "type": ".google.cloud.retail.v2alpha.Control" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_GetControl_async", - "title": "CatalogService getControl Sample", - "origin": "API_DEFINITION", - "description": " Gets a Control.", - "canonical": true, - "file": "control_service.get_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ControlService_ListControls_async", - "title": "CatalogService listControls Sample", - "origin": "API_DEFINITION", - "description": " Lists all Controls linked to this catalog.", - "canonical": true, - "file": "control_service.list_controls.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ListControlsResponse", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" - }, - "method": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2alpha.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_PredictionService_Predict_async", - "title": "CatalogService predict Sample", - "origin": "API_DEFINITION", - "description": " Makes a recommendation prediction.", - "canonical": true, - "file": "prediction_service.predict.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 153, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2alpha.UserEvent" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "params", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.retail.v2alpha.PredictResponse", - "client": { - "shortName": "PredictionServiceClient", - "fullName": "google.cloud.retail.v2alpha.PredictionServiceClient" - }, - "method": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", - "service": { - "shortName": "PredictionService", - "fullName": "google.cloud.retail.v2alpha.PredictionService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_CreateProduct_async", - "title": "CatalogService createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Product][google.cloud.retail.v2alpha.Product].", - "canonical": true, - "file": "product_service.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.retail.v2alpha.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_GetProduct_async", - "title": "CatalogService getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Product][google.cloud.retail.v2alpha.Product].", - "canonical": true, - "file": "product_service.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_ListProducts_async", - "title": "CatalogService listProducts Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Product][google.cloud.retail.v2alpha.Product]s.", - "canonical": true, - "file": "product_service.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 133, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "read_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "require_total_size", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ListProductsResponse", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_UpdateProduct_async", - "title": "CatalogService updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Product][google.cloud.retail.v2alpha.Product].", - "canonical": true, - "file": "product_service.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.retail.v2alpha.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_DeleteProduct_async", - "title": "CatalogService deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Product][google.cloud.retail.v2alpha.Product].", - "canonical": true, - "file": "product_service.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_PurgeProducts_async", - "title": "CatalogService purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes all selected [Product][google.cloud.retail.v2alpha.Product]s under a branch. This process is asynchronous. If the request is valid, the removal will be enqueued and processed offline. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. Before the operation completes, some [Product][google.cloud.retail.v2alpha.Product]s may still be returned by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. To get a sample of [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] to false.", - "canonical": true, - "file": "product_service.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 93, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_ImportProducts_async", - "title": "CatalogService importProducts Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated.", - "canonical": true, - "file": "product_service.import_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 85, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2alpha.ProductInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "reconciliation_mode", - "type": ".google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_SetInventory_async", - "title": "CatalogService setInventory Sample", - "origin": "API_DEFINITION", - "description": " Updates inventory information for a [Product][google.cloud.retail.v2alpha.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.set_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 116, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", - "async": true, - "parameters": [ - { - "name": "inventory", - "type": ".google.cloud.retail.v2alpha.Product" - }, - { - "name": "set_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "set_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async", - "title": "CatalogService addFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 107, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async", - "title": "CatalogService removeFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 103, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_AddLocalInventories_async", - "title": "CatalogService addLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Updates local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 92, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "local_inventories", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "add_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ProductService_RemoveLocalInventories_async", - "title": "CatalogService removeLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Remove local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" - }, - "method": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2alpha.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_SearchService_Search_async", - "title": "CatalogService search Sample", - "origin": "API_DEFINITION", - "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 273, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2alpha.SearchService.Search", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "branch", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "user_info", - "type": ".google.cloud.retail.v2alpha.UserInfo" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "offset", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "canonical_filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "facet_specs", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "dynamic_facet_spec", - "type": ".google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec" - }, - { - "name": "boost_spec", - "type": ".google.cloud.retail.v2alpha.SearchRequest.BoostSpec" - }, - { - "name": "query_expansion_spec", - "type": ".google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec" - }, - { - "name": "relevance_threshold", - "type": ".google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold" - }, - { - "name": "variant_rollup_keys", - "type": "TYPE_STRING[]" - }, - { - "name": "page_categories", - "type": "TYPE_STRING[]" - }, - { - "name": "search_mode", - "type": ".google.cloud.retail.v2alpha.SearchRequest.SearchMode" - }, - { - "name": "personalization_spec", - "type": ".google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec" - } - ], - "resultType": ".google.cloud.retail.v2alpha.SearchResponse", - "client": { - "shortName": "SearchServiceClient", - "fullName": "google.cloud.retail.v2alpha.SearchServiceClient" - }, - "method": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2alpha.SearchService.Search", - "service": { - "shortName": "SearchService", - "fullName": "google.cloud.retail.v2alpha.SearchService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async", - "title": "CatalogService createServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a FAILED_PRECONDITION error is returned.", - "canonical": true, - "file": "serving_config_service.create_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "serving_config", - "type": ".google.cloud.retail.v2alpha.ServingConfig" - }, - { - "name": "serving_config_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async", - "title": "CatalogService deleteServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", - "canonical": true, - "file": "serving_config_service.delete_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async", - "title": "CatalogService updateServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates a ServingConfig.", - "canonical": true, - "file": "serving_config_service.update_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": ".google.cloud.retail.v2alpha.ServingConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_GetServingConfig_async", - "title": "CatalogService getServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", - "canonical": true, - "file": "serving_config_service.get_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async", - "title": "CatalogService listServingConfigs Sample", - "origin": "API_DEFINITION", - "description": " Lists all ServingConfigs linked to this catalog.", - "canonical": true, - "file": "serving_config_service.list_serving_configs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ListServingConfigsResponse", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_AddControl_async", - "title": "CatalogService addControl Sample", - "origin": "API_DEFINITION", - "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", - "canonical": true, - "file": "serving_config_service.add_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ServingConfigService_RemoveControl_async", - "title": "CatalogService removeControl Sample", - "origin": "API_DEFINITION", - "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", - "canonical": true, - "file": "serving_config_service.remove_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" - }, - "method": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2alpha.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_WriteUserEvent_async", - "title": "CatalogService writeUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event.", - "canonical": true, - "file": "user_event_service.write_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2alpha.UserEvent" - } - ], - "resultType": ".google.cloud.retail.v2alpha.UserEvent", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_CollectUserEvent_async", - "title": "CatalogService collectUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", - "canonical": true, - "file": "user_event_service.collect_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.api.HttpBody", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_PurgeUserEvents_async", - "title": "CatalogService purgeUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", - "canonical": true, - "file": "user_event_service.purge_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 83, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_ImportUserEvents_async", - "title": "CatalogService importUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", - "canonical": true, - "file": "user_event_service.import_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2alpha.UserEventInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_UserEventService_RejoinUserEvents_async", - "title": "CatalogService rejoinUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", - "canonical": true, - "file": "user_event_service.rejoin_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event_rejoin_scope", - "type": ".google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" - }, - "method": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2alpha.UserEventService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js deleted file mode 100644 index 2c259bbf..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2alpha_generated_UserEventService_CollectUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - */ - // const userEvent = 'abc123' - /** - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - */ - // const uri = 'abc123' - /** - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - */ - // const ets = 1234 - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callCollectUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.collectUserEvent(request); - console.log(response); - } - - callCollectUserEvent(); - // [END retail_v2alpha_generated_UserEventService_CollectUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js deleted file mode 100644 index 733e1b2f..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2alpha_generated_UserEventService_ImportUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. `projects/1234/locations/global/catalogs/default_catalog` - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - */ - // const errorsConfig = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callImportUserEvents() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportUserEvents(); - // [END retail_v2alpha_generated_UserEventService_ImportUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js deleted file mode 100644 index 9d1d604c..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, filter) { - // [START retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - */ - // const parent = 'abc123' - /** - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * * `eventType`: Double quoted - * UserEvent.event_type google.cloud.retail.v2alpha.UserEvent.event_type - * string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * Examples: - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * The filtering fields are assumed to have an implicit AND. - */ - // const filter = 'abc123' - /** - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - */ - // const force = true - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callPurgeUserEvents() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await retailClient.purgeUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeUserEvents(); - // [END retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js deleted file mode 100644 index e72b2378..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - */ - // const userEventRejoinScope = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callRejoinUserEvents() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await retailClient.rejoinUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRejoinUserEvents(); - // [END retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js b/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js deleted file mode 100644 index 8742b980..00000000 --- a/owl-bot-staging/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2alpha_generated_UserEventService_WriteUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callWriteUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.writeUserEvent(request); - console.log(response); - } - - callWriteUserEvent(); - // [END retail_v2alpha_generated_UserEventService_WriteUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2alpha/src/index.ts b/owl-bot-staging/v2alpha/src/index.ts deleted file mode 100644 index ebdb9c41..00000000 --- a/owl-bot-staging/v2alpha/src/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 v2alpha from './v2alpha'; -const CatalogServiceClient = v2alpha.CatalogServiceClient; -type CatalogServiceClient = v2alpha.CatalogServiceClient; -const CompletionServiceClient = v2alpha.CompletionServiceClient; -type CompletionServiceClient = v2alpha.CompletionServiceClient; -const ControlServiceClient = v2alpha.ControlServiceClient; -type ControlServiceClient = v2alpha.ControlServiceClient; -const PredictionServiceClient = v2alpha.PredictionServiceClient; -type PredictionServiceClient = v2alpha.PredictionServiceClient; -const ProductServiceClient = v2alpha.ProductServiceClient; -type ProductServiceClient = v2alpha.ProductServiceClient; -const SearchServiceClient = v2alpha.SearchServiceClient; -type SearchServiceClient = v2alpha.SearchServiceClient; -const ServingConfigServiceClient = v2alpha.ServingConfigServiceClient; -type ServingConfigServiceClient = v2alpha.ServingConfigServiceClient; -const UserEventServiceClient = v2alpha.UserEventServiceClient; -type UserEventServiceClient = v2alpha.UserEventServiceClient; -export {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -export default {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts deleted file mode 100644 index c1af21ae..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client.ts +++ /dev/null @@ -1,1865 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/catalog_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './catalog_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for managing catalog configuration. - * @class - * @memberof v2alpha - */ -export class CatalogServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - catalogServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CatalogServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CatalogServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listCatalogs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.CatalogService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.catalogServiceStub) { - return this.catalogServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.CatalogService. - this.catalogServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.CatalogService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.CatalogService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const catalogServiceStubMethods = - ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch', 'getCompletionConfig', 'updateCompletionConfig', 'getAttributesConfig', 'updateAttributesConfig', 'addCatalogAttribute', 'removeCatalogAttribute', 'replaceCatalogAttribute']; - for (const methodName of catalogServiceStubMethods) { - const callPromise = this.catalogServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.catalogServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Updates the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.Catalog} request.catalog - * Required. The {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2alpha.Catalog|Catalog}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update does not - * exist, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.update_catalog.js - * region_tag:retail_v2alpha_generated_CatalogService_UpdateCatalog_async - */ - updateCatalog( - request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|undefined, {}|undefined - ]>; - updateCatalog( - request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICatalog, - protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog.name': request.catalog!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCatalog(request, options, callback); - } -/** - * Set a specified branch id as default branch. API methods such as - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search}, - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct}, - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * will treat requests using "default_branch" to the actual branch id set as - * default. - * - * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as - * default, setting - * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent - * to setting - * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/1`. - * - * Using multiple branches can be useful when developers would like - * to have a staging branch to test and verify for future usage. When it - * becomes ready, developers switch on the staging branch using this API while - * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` - * as {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} - * to route the traffic to this staging branch. - * - * CAUTION: If you have live predict/search traffic, switching the default - * branch could potentially cause outages if the ID space of the new branch is - * very different from the old one. - * - * More specifically: - * - * * PredictionService will only return product IDs from branch {newBranch}. - * * SearchService will only return product IDs from branch {newBranch} - * (if branch is not explicitly set). - * * UserEventService will only join events with products from branch - * {newBranch}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.branchId - * The final component of the resource name of a branch. - * - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * - * If there are no sufficient active products in the targeted branch and - * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.force|force} is not - * set, a FAILED_PRECONDITION error is returned. - * @param {string} request.note - * Some note on this request, this can be retrieved by - * {@link google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} - * before next valid default branch set occurs. - * - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {boolean} request.force - * If set to true, it permits switching to a branch with - * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id|branch_id} - * even if it has no sufficient active products. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.set_default_branch.js - * region_tag:retail_v2alpha_generated_CatalogService_SetDefaultBranch_async - */ - setDefaultBranch( - request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|undefined, {}|undefined - ]>; - setDefaultBranch( - request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.setDefaultBranch(request, options, callback); - } -/** - * Get which branch is currently default branch set by - * {@link google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} - * method under a specified parent catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2alpha.GetDefaultBranchResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.get_default_branch.js - * region_tag:retail_v2alpha_generated_CatalogService_GetDefaultBranch_async - */ - getDefaultBranch( - request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|undefined, {}|undefined - ]>; - getDefaultBranch( - request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.getDefaultBranch(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full CompletionConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.get_completion_config.js - * region_tag:retail_v2alpha_generated_CatalogService_GetCompletionConfig_async - */ - getCompletionConfig( - request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|undefined, {}|undefined - ]>; - getCompletionConfig( - request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getCompletionConfig(request, options, callback); - } -/** - * Updates the - * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.CompletionConfig} request.completionConfig - * Required. The - * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}, then a - * PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to - * update does not exist, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. - * The following are the only supported fields: - * - * * {@link google.cloud.retail.v2alpha.CompletionConfig.matching_order|CompletionConfig.matching_order} - * * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} - * * {@link google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} - * * {@link google.cloud.retail.v2alpha.CompletionConfig.auto_learning|CompletionConfig.auto_learning} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.update_completion_config.js - * region_tag:retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async - */ - updateCompletionConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|undefined, {}|undefined - ]>; - updateCompletionConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompletionConfig, - protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'completion_config.name': request.completionConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCompletionConfig(request, options, callback); - } -/** - * Gets an {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.get_attributes_config.js - * region_tag:retail_v2alpha_generated_CatalogService_GetAttributesConfig_async - */ - getAttributesConfig( - request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|undefined, {}|undefined - ]>; - getAttributesConfig( - request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getAttributesConfig(request, options, callback); - } -/** - * Updates the - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * The catalog attributes in the request will be updated in the catalog, or - * inserted if they do not exist. Existing catalog attributes not included in - * the request will remain unchanged. Attributes that are assigned to - * products, but do not exist at the catalog level, are always included in the - * response. The product attribute is assigned default values for missing - * catalog attribute fields, e.g., searchable and dynamic facetable options. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.AttributesConfig} request.attributesConfig - * Required. The - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. - * The following is the only supported field: - * - * * {@link google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.update_attributes_config.js - * region_tag:retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async - */ - updateAttributesConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|undefined, {}|undefined - ]>; - updateAttributesConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config.name': request.attributesConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateAttributesConfig(request, options, callback); - } -/** - * Adds the specified - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to the - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to - * add already exists, an ALREADY_EXISTS error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute - * Required. The - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to add. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.add_catalog_attribute.js - * region_tag:retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async - */ - addCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|undefined, {}|undefined - ]>; - addCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.addCatalogAttribute(request, options, callback); - } -/** - * Removes the specified - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} from the - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to - * remove does not exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {string} request.key - * Required. The attribute name key of the - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to remove. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js - * region_tag:retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async - */ - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|undefined, {}|undefined - ]>; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.removeCatalogAttribute(request, options, callback); - } -/** - * Replaces the specified - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} in the - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} by - * updating the catalog attribute with the same - * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key}. - * - * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to - * replace does not exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute - * Required. The updated - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to update. - * The following are NOT supported: - * - * * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js - * region_tag:retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async - */ - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|undefined, {}|undefined - ]>; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IAttributesConfig, - protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.replaceCatalogAttribute(request, options, callback); - } - - /** - * Lists all the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s associated - * with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to - * return. If unspecified, defaults to 50. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogs( - request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICatalog[], - protos.google.cloud.retail.v2alpha.IListCatalogsRequest|null, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse - ]>; - listCatalogs( - request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.ICatalog>): void; - listCatalogs( - request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.ICatalog>): void; - listCatalogs( - request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.ICatalog>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.ICatalog>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICatalog[], - protos.google.cloud.retail.v2alpha.IListCatalogsRequest|null, - protos.google.cloud.retail.v2alpha.IListCatalogsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listCatalogs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to - * return. If unspecified, defaults to 50. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2alpha.Catalog} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogsStream( - request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.createStream( - this.innerApiCalls.listCatalogs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listCatalogs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to - * return. If unspecified, defaults to 50. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/catalog_service.list_catalogs.js - * region_tag:retail_v2alpha_generated_CatalogService_ListCatalogs_async - */ - listCatalogsAsync( - request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.asyncIterate( - this.innerApiCalls['listCatalogs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.catalogServiceStub && !this._terminated) { - return this.catalogServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json deleted file mode 100644 index 08407daa..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_client_config.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.CatalogService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListCatalogs": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCatalog": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "SetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetCompletionConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCompletionConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetAttributesConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateAttributesConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "AddCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "RemoveCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ReplaceCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/catalog_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts deleted file mode 100644 index 36be33c4..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client.ts +++ /dev/null @@ -1,936 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/completion_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './completion_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Auto-completion service for retail. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2alpha - */ -export class CompletionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - completionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CompletionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CompletionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importCompletionDataResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportCompletionDataResponse') as gax.protobuf.Type; - const importCompletionDataMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importCompletionData: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importCompletionDataResponse.decode.bind(importCompletionDataResponse), - importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.CompletionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.completionServiceStub) { - return this.completionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.CompletionService. - this.completionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.CompletionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.CompletionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const completionServiceStubMethods = - ['completeQuery', 'importCompletionData']; - for (const methodName of completionServiceStubMethods) { - const callPromise = this.completionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.completionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Completes the specified prefix with keyword suggestions. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Required. Catalog for which the completion is performed. - * - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.query - * Required. The query used to generate suggestions. - * - * The maximum number of allowed characters is 255. - * @param {string} request.visitorId - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {string[]} request.languageCodes - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see [Tags for - * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - * @param {string} request.deviceType - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * - * Supported formats: - * - * * `UNKNOWN_DEVICE_TYPE` - * - * * `DESKTOP` - * - * * `MOBILE` - * - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - * @param {string} request.dataset - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * {@link google.cloud.retail.v2alpha.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * - * Current supported values: - * - * * user-data - * - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - * @param {number} request.maxSuggestions - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value - * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. - * - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2alpha.CompleteQueryResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/completion_service.complete_query.js - * region_tag:retail_v2alpha_generated_CompletionService_CompleteQuery_async - */ - completeQuery( - request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|undefined, {}|undefined - ]>; - completeQuery( - request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, - protos.google.cloud.retail.v2alpha.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.completeQuery(request, options, callback); - } - -/** - * Bulk import of processed completion dataset. - * - * Request processing is asynchronous. Partial updating is not supported. - * - * The operation is successfully finished only after the imported suggestions - * are indexed successfully and ready for serving. The process takes hours. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog which the suggestions dataset belongs to. - * - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2alpha.CompletionDataInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js - * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async - */ - importCompletionData( - request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importCompletionData( - request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importCompletionData(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importCompletionData()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js - * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async - */ - async checkImportCompletionDataProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.completionServiceStub && !this._terminated) { - return this.completionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json deleted file mode 100644 index ac2795a5..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_client_config.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.CompletionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CompleteQuery": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ImportCompletionData": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/completion_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts deleted file mode 100644 index bef33ee7..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client.ts +++ /dev/null @@ -1,1195 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/control_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './control_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for modifying Control. - * @class - * @memberof v2alpha - */ -export class ControlServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - controlServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ControlServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ControlServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listControls: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'controls') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.ControlService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.controlServiceStub) { - return this.controlServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.ControlService. - this.controlServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ControlService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.ControlService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const controlServiceStubMethods = - ['createControl', 'deleteControl', 'updateControl', 'getControl', 'listControls']; - for (const methodName of controlServiceStubMethods) { - const callPromise = this.controlServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.controlServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a Control. - * - * If the {@link google.cloud.retail.v2alpha.Control|Control} to create already - * exists, an ALREADY_EXISTS error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full resource name of parent catalog. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {google.cloud.retail.v2alpha.Control} request.control - * Required. The Control to create. - * @param {string} request.controlId - * Required. The ID to use for the Control, which will become the final - * component of the Control's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link 0-9|a-z}-_/. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.create_control.js - * region_tag:retail_v2alpha_generated_ControlService_CreateControl_async - */ - createControl( - request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|undefined, {}|undefined - ]>; - createControl( - request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.ICreateControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createControl(request, options, callback); - } -/** - * Deletes a Control. - * - * If the {@link google.cloud.retail.v2alpha.Control|Control} to delete does not - * exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.delete_control.js - * region_tag:retail_v2alpha_generated_ControlService_DeleteControl_async - */ - deleteControl( - request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|undefined, {}|undefined - ]>; - deleteControl( - request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteControl(request, options, callback); - } -/** - * Updates a Control. - * - * {@link google.cloud.retail.v2alpha.Control|Control} cannot be set to a different - * oneof field, if so an INVALID_ARGUMENT is returned. If the - * {@link google.cloud.retail.v2alpha.Control|Control} to delete does not exist, a - * NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.Control} request.control - * Required. The Control to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.Control|Control} to update. The following are - * NOT supported: - * - * * {@link google.cloud.retail.v2alpha.Control.name|Control.name} - * - * If not set or empty, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.update_control.js - * region_tag:retail_v2alpha_generated_ControlService_UpdateControl_async - */ - updateControl( - request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|undefined, {}|undefined - ]>; - updateControl( - request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IUpdateControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'control.name': request.control!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateControl(request, options, callback); - } -/** - * Gets a Control. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.get_control.js - * region_tag:retail_v2alpha_generated_ControlService_GetControl_async - */ - getControl( - request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|undefined, {}|undefined - ]>; - getControl( - request: protos.google.cloud.retail.v2alpha.IGetControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request: protos.google.cloud.retail.v2alpha.IGetControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl, - protos.google.cloud.retail.v2alpha.IGetControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getControl(request, options, callback); - } - - /** - * Lists all Controls linked to this catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Control]{@link google.cloud.retail.v2alpha.Control}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listControlsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listControls( - request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl[], - protos.google.cloud.retail.v2alpha.IListControlsRequest|null, - protos.google.cloud.retail.v2alpha.IListControlsResponse - ]>; - listControls( - request: protos.google.cloud.retail.v2alpha.IListControlsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListControlsRequest, - protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IControl>): void; - listControls( - request: protos.google.cloud.retail.v2alpha.IListControlsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListControlsRequest, - protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IControl>): void; - listControls( - request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.IListControlsRequest, - protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IControl>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListControlsRequest, - protos.google.cloud.retail.v2alpha.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IControl>): - Promise<[ - protos.google.cloud.retail.v2alpha.IControl[], - protos.google.cloud.retail.v2alpha.IListControlsRequest|null, - protos.google.cloud.retail.v2alpha.IListControlsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listControls(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Control]{@link google.cloud.retail.v2alpha.Control} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listControlsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listControlsStream( - request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listControls']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listControls.createStream( - this.innerApiCalls.listControls as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listControls`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Control]{@link google.cloud.retail.v2alpha.Control}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/control_service.list_controls.js - * region_tag:retail_v2alpha_generated_ControlService_ListControls_async - */ - listControlsAsync( - request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listControls']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listControls.asyncIterate( - this.innerApiCalls['listControls'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.controlServiceStub && !this._terminated) { - return this.controlServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json deleted file mode 100644 index 9a86d786..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/control_service_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.ControlService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListControls": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/control_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json b/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json deleted file mode 100644 index aeabbe19..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/gapic_metadata.json +++ /dev/null @@ -1,581 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.retail.v2alpha", - "libraryPackage": "@google-cloud/retail", - "services": { - "CatalogService": { - "clients": { - "grpc": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "GetCompletionConfig": { - "methods": [ - "getCompletionConfig" - ] - }, - "UpdateCompletionConfig": { - "methods": [ - "updateCompletionConfig" - ] - }, - "GetAttributesConfig": { - "methods": [ - "getAttributesConfig" - ] - }, - "UpdateAttributesConfig": { - "methods": [ - "updateAttributesConfig" - ] - }, - "AddCatalogAttribute": { - "methods": [ - "addCatalogAttribute" - ] - }, - "RemoveCatalogAttribute": { - "methods": [ - "removeCatalogAttribute" - ] - }, - "ReplaceCatalogAttribute": { - "methods": [ - "replaceCatalogAttribute" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "GetCompletionConfig": { - "methods": [ - "getCompletionConfig" - ] - }, - "UpdateCompletionConfig": { - "methods": [ - "updateCompletionConfig" - ] - }, - "GetAttributesConfig": { - "methods": [ - "getAttributesConfig" - ] - }, - "UpdateAttributesConfig": { - "methods": [ - "updateAttributesConfig" - ] - }, - "AddCatalogAttribute": { - "methods": [ - "addCatalogAttribute" - ] - }, - "RemoveCatalogAttribute": { - "methods": [ - "removeCatalogAttribute" - ] - }, - "ReplaceCatalogAttribute": { - "methods": [ - "replaceCatalogAttribute" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - } - } - }, - "CompletionService": { - "clients": { - "grpc": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - } - } - }, - "ControlService": { - "clients": { - "grpc": { - "libraryClient": "ControlServiceClient", - "rpcs": { - "CreateControl": { - "methods": [ - "createControl" - ] - }, - "DeleteControl": { - "methods": [ - "deleteControl" - ] - }, - "UpdateControl": { - "methods": [ - "updateControl" - ] - }, - "GetControl": { - "methods": [ - "getControl" - ] - }, - "ListControls": { - "methods": [ - "listControls", - "listControlsStream", - "listControlsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ControlServiceClient", - "rpcs": { - "CreateControl": { - "methods": [ - "createControl" - ] - }, - "DeleteControl": { - "methods": [ - "deleteControl" - ] - }, - "UpdateControl": { - "methods": [ - "updateControl" - ] - }, - "GetControl": { - "methods": [ - "getControl" - ] - }, - "ListControls": { - "methods": [ - "listControls", - "listControlsStream", - "listControlsAsync" - ] - } - } - } - } - }, - "PredictionService": { - "clients": { - "grpc": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - } - } - }, - "ProductService": { - "clients": { - "grpc": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - } - } - }, - "SearchService": { - "clients": { - "grpc": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - } - } - }, - "ServingConfigService": { - "clients": { - "grpc": { - "libraryClient": "ServingConfigServiceClient", - "rpcs": { - "CreateServingConfig": { - "methods": [ - "createServingConfig" - ] - }, - "DeleteServingConfig": { - "methods": [ - "deleteServingConfig" - ] - }, - "UpdateServingConfig": { - "methods": [ - "updateServingConfig" - ] - }, - "GetServingConfig": { - "methods": [ - "getServingConfig" - ] - }, - "AddControl": { - "methods": [ - "addControl" - ] - }, - "RemoveControl": { - "methods": [ - "removeControl" - ] - }, - "ListServingConfigs": { - "methods": [ - "listServingConfigs", - "listServingConfigsStream", - "listServingConfigsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ServingConfigServiceClient", - "rpcs": { - "CreateServingConfig": { - "methods": [ - "createServingConfig" - ] - }, - "DeleteServingConfig": { - "methods": [ - "deleteServingConfig" - ] - }, - "UpdateServingConfig": { - "methods": [ - "updateServingConfig" - ] - }, - "GetServingConfig": { - "methods": [ - "getServingConfig" - ] - }, - "AddControl": { - "methods": [ - "addControl" - ] - }, - "RemoveControl": { - "methods": [ - "removeControl" - ] - }, - "ListServingConfigs": { - "methods": [ - "listServingConfigs", - "listServingConfigsStream", - "listServingConfigsAsync" - ] - } - } - } - } - }, - "UserEventService": { - "clients": { - "grpc": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/index.ts b/owl-bot-staging/v2alpha/src/v2alpha/index.ts deleted file mode 100644 index a7e4f6ba..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {CatalogServiceClient} from './catalog_service_client'; -export {CompletionServiceClient} from './completion_service_client'; -export {ControlServiceClient} from './control_service_client'; -export {PredictionServiceClient} from './prediction_service_client'; -export {ProductServiceClient} from './product_service_client'; -export {SearchServiceClient} from './search_service_client'; -export {ServingConfigServiceClient} from './serving_config_service_client'; -export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts deleted file mode 100644 index 6a5d9153..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client.ts +++ /dev/null @@ -1,837 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/prediction_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './prediction_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for making recommendation prediction. - * @class - * @memberof v2alpha - */ -export class PredictionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - predictionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PredictionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PredictionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.PredictionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.predictionServiceStub) { - return this.predictionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.PredictionService. - this.predictionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.PredictionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.PredictionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const predictionServiceStubMethods = - ['predict']; - for (const methodName of predictionServiceStubMethods) { - const callPromise = this.predictionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.predictionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Makes a recommendation prediction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see [Managing - * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - * @param {number} request.pageSize - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - * @param {string} request.pageToken - * The previous PredictResponse.next_page_token. - * @param {string} request.filter - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * - * Examples: - * - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - * @param {boolean} request.validateOnly - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - * @param {number[]} request.params - * Additional domain specific parameters for the predictions. - * - * Allowed values: - * - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - * @param {number[]} request.labels - * The labels applied to a resource must meet the following requirements: - * - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * - * See [Google Cloud - * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2alpha.PredictResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/prediction_service.predict.js - * region_tag:retail_v2alpha_generated_PredictionService_Predict_async - */ - predict( - request?: protos.google.cloud.retail.v2alpha.IPredictRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|undefined, {}|undefined - ]>; - predict( - request: protos.google.cloud.retail.v2alpha.IPredictRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request: protos.google.cloud.retail.v2alpha.IPredictRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request?: protos.google.cloud.retail.v2alpha.IPredictRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IPredictResponse, - protos.google.cloud.retail.v2alpha.IPredictRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.predict(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.predictionServiceStub && !this._terminated) { - return this.predictionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json deleted file mode 100644 index ed48fe50..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.PredictionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Predict": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/prediction_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts deleted file mode 100644 index 0d593a5e..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client.ts +++ /dev/null @@ -1,2641 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/product_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting {@link google.cloud.retail.v2alpha.Product|Product} - * information of the customer's website. - * @class - * @memberof v2alpha - */ -export class ProductServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ProductServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.PurgeProductsResponse') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.PurgeProductsMetadata') as gax.protobuf.Type; - const importProductsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportProductsResponse') as gax.protobuf.Type; - const importProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; - const setInventoryResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.SetInventoryResponse') as gax.protobuf.Type; - const setInventoryMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.SetInventoryMetadata') as gax.protobuf.Type; - const addFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse') as gax.protobuf.Type; - const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; - const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; - const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; - const addLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.AddLocalInventoriesResponse') as gax.protobuf.Type; - const addLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata') as gax.protobuf.Type; - const removeLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse') as gax.protobuf.Type; - const removeLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)), - importProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductsResponse.decode.bind(importProductsResponse), - importProductsMetadata.decode.bind(importProductsMetadata)), - setInventory: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInventoryResponse.decode.bind(setInventoryResponse), - setInventoryMetadata.decode.bind(setInventoryMetadata)), - addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), - addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), - removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), - removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), - addLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), - addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), - removeLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), - removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.ProductService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.productServiceStub) { - return this.productServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.ProductService. - this.productServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ProductService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.ProductService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const productServiceStubMethods = - ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'purgeProducts', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; - for (const methodName of productServiceStubMethods) { - const callPromise = this.productServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.productServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a {@link google.cloud.retail.v2alpha.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - * @param {google.cloud.retail.v2alpha.Product} request.product - * Required. The {@link google.cloud.retail.v2alpha.Product|Product} to create. - * @param {string} request.productId - * Required. The ID to use for the - * {@link google.cloud.retail.v2alpha.Product|Product}, which will become the final - * component of the {@link google.cloud.retail.v2alpha.Product.name|Product.name}. - * - * If the caller does not have permission to create the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * This field must be unique among all - * {@link google.cloud.retail.v2alpha.Product|Product}s with the same - * {@link google.cloud.retail.v2alpha.CreateProductRequest.parent|parent}. - * Otherwise, an ALREADY_EXISTS error is returned. - * - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.create_product.js - * region_tag:retail_v2alpha_generated_ProductService_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2alpha.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the requested {@link google.cloud.retail.v2alpha.Product|Product} does not - * exist, a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.get_product.js - * region_tag:retail_v2alpha_generated_ProductService_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.retail.v2alpha.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.retail.v2alpha.IGetProductRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Updates a {@link google.cloud.retail.v2alpha.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.Product} request.product - * Required. The product to update/create. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not - * exist and - * {@link google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing|allow_missing} - * is not set, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.Product|Product} to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, a new {@link google.cloud.retail.v2alpha.Product|Product} will be - * created. In this situation, `update_mask` is ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2alpha.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.update_product.js - * region_tag:retail_v2alpha_generated_ProductService_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct, - protos.google.cloud.retail.v2alpha.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Deletes a {@link google.cloud.retail.v2alpha.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to delete the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.Product|Product} to delete does not - * exist, a NOT_FOUND error is returned. - * - * The {@link google.cloud.retail.v2alpha.Product|Product} to delete can neither be - * a - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product} member nor a - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product} with more than one - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variants}. Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * All inventory information for the named - * {@link google.cloud.retail.v2alpha.Product|Product} will be deleted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.delete_product.js - * region_tag:retail_v2alpha_generated_ProductService_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } - -/** - * Permanently deletes all selected - * {@link google.cloud.retail.v2alpha.Product|Product}s under a branch. - * - * This process is asynchronous. If the request is valid, the removal will be - * enqueued and processed offline. Depending on the number of - * {@link google.cloud.retail.v2alpha.Product|Product}s, this operation could take - * hours to complete. Before the operation completes, some - * {@link google.cloud.retail.v2alpha.Product|Product}s may still be returned by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * Depending on the number of {@link google.cloud.retail.v2alpha.Product|Product}s, - * this operation could take hours to complete. To get a sample of - * {@link google.cloud.retail.v2alpha.Product|Product}s that would be deleted, set - * {@link google.cloud.retail.v2alpha.PurgeProductsRequest.force|PurgeProductsRequest.force} - * to false. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the branch under which the products are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` - * @param {string} request.filter - * Required. The filter string to specify the products to be deleted with a - * length limit of 5,000 characters. - * - * Empty string filter is not allowed. "*" implies delete all items in a - * branch. - * - * The eligible fields for filtering are: - * - * * `availability`: Double quoted - * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} - * string. - * * `create_time` : in ISO 8601 "zulu" format. - * - * Supported syntax: - * - * * Comparators (">", "<", ">=", "<=", "="). - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" - * * availability = "IN_STOCK" - * - * * Conjunctions ("AND") - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" - * - * * Disjunctions ("OR") - * Examples: - * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" - * - * * Can support nested queries. - * Examples: - * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") - * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") - * - * * Filter Limits: - * * Filter should not contain more than 6 conditions. - * * Max nesting depth should not exceed 2 levels. - * - * Examples queries: - * * Delete back order products created before a timestamp. - * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" - * @param {boolean} request.force - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any products. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.purge_products.js - * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.retail.v2alpha.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' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.purge_products.js - * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async - */ - async checkPurgeProductsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeProducts, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Bulk import of multiple {@link google.cloud.retail.v2alpha.Product|Product}s. - * - * Request processing may be synchronous. No partial updating is supported. - * Non-existing items are created. - * - * Note that it is possible for a subset of the - * {@link google.cloud.retail.v2alpha.Product|Product}s to be successfully updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - * @param {string} request.requestId - * Deprecated. This field has no effect. - * @param {google.cloud.retail.v2alpha.ProductInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - * @param {google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode} request.reconciliationMode - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * {@link google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * - * Only supported when - * {@link google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} - * is set to `FULL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.import_products.js - * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async - */ - importProducts( - request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProducts( - request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.import_products.js - * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async - */ - async checkImportProductsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates inventory information for a - * {@link google.cloud.retail.v2alpha.Product|Product} while respecting the last - * update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, updates are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * When inventory is updated with - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct}, - * the specified inventory field value(s) will overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update time for the specified inventory fields will be overwritten to the - * time of the - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} - * or - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} - * request. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2alpha.CreateProductRequest.product|CreateProductRequest.product}, - * then any pre-existing inventory information for this product will be used. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, - * then any existing inventory information will be preserved. - * - * Pre-existing inventory information can only be updated with - * {@link google.cloud.retail.v2alpha.ProductService.SetInventory|SetInventory}, - * {@link google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, - * and - * {@link google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.Product} request.inventory - * Required. The inventory information to update. The allowable fields to - * update are: - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} - * The updated inventory fields must be specified in - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. - * - * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2alpha.Product|Product} named in - * {@link google.cloud.retail.v2alpha.Product.name|Product.name}, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * - * If the {@link google.cloud.retail.v2alpha.Product|Product} to update has - * existing inventory information, the provided inventory information will be - * merged while respecting the last update time for each inventory field, - * using the provided or default value for - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. - * - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} - * - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types to clear in - * {@link |SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} - * - * The last update time is recorded for the following inventory fields: - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} - * - * If a full overwrite of inventory information while ignoring timestamps is - * needed, {@link |UpdateProduct} should be invoked instead. - * @param {google.protobuf.FieldMask} request.setMask - * Indicates which inventory fields in the provided - * {@link google.cloud.retail.v2alpha.Product|Product} to update. - * - * At least one field must be provided. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.setTime - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} with - * name {@link google.cloud.retail.v2alpha.Product.name|Product.name} is not found, - * the inventory update will still be processed and retained for at most 1 day - * until the {@link google.cloud.retail.v2alpha.Product|Product} is created. If set - * to false, a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.set_inventory.js - * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async - */ - setInventory( - request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInventory( - request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'inventory.name': request.inventory!.name || '', - }); - this.initialize(); - return this.innerApiCalls.setInventory(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInventory()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.set_inventory.js - * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async - */ - async checkSetInventoryProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally adds place IDs to - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the added place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}, such - * as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}. - * Duplicate IDs will be automatically ignored. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * If the total number of place IDs exceeds 2000 for this - * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type} after - * adding, then the update will be rejected. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js - * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async - */ - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js - * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async - */ - async checkAddFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally removes place IDs from a - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the removed place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}, - * such as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js - * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async - */ - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js - * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async - */ - async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates local inventory information for a - * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places, while - * respecting the last update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating - * inventory information. If the request is valid, the update will be enqueued - * and processed downstream. As a consequence, when a response is returned, - * updates are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} - * has no effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * @param {number[]} request.localInventories - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - * @param {google.protobuf.FieldMask} request.addMask - * Indicates which inventory fields in the provided list of - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory} to update. The - * field is updated to the provided value. - * - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, the local inventory will still be processed and retained for at - * most 1 day and processed once the - * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js - * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async - */ - addLocalInventories( - request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addLocalInventories( - request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js - * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async - */ - async checkAddLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Remove local inventory information for a - * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places at a - * removal timestamp. - * - * This process is asynchronous. If the request is valid, the removal will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, removals are not immediately manifested in the - * {@link google.cloud.retail.v2alpha.Product|Product} queried by - * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|UpdateProduct} - * has no effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2alpha.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or - * not it exists, a PERMISSION_DENIED error is returned. - * @param {string[]} request.placeIds - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is - * not found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2alpha.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js - * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async - */ - removeLocalInventories( - request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeLocalInventories( - request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js - * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async - */ - async checkRemoveLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.retail.v2alpha.Product|Product}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to 100. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product} or - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} - * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} - * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} - * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.requireTotalSize - * If true and - * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is - * empty, - * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} - * is set to the total count of matched items irrespective of pagination. - * - * Notice that setting this field to true affects the performance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.retail.v2alpha.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct[], - protos.google.cloud.retail.v2alpha.IListProductsRequest|null, - protos.google.cloud.retail.v2alpha.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.retail.v2alpha.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListProductsRequest, - protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IProduct>): void; - listProducts( - request: protos.google.cloud.retail.v2alpha.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListProductsRequest, - protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IProduct>): void; - listProducts( - request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.IListProductsRequest, - protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListProductsRequest, - protos.google.cloud.retail.v2alpha.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IProduct>): - Promise<[ - protos.google.cloud.retail.v2alpha.IProduct[], - protos.google.cloud.retail.v2alpha.IListProductsRequest|null, - protos.google.cloud.retail.v2alpha.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to 100. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product} or - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} - * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} - * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} - * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.requireTotalSize - * If true and - * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is - * empty, - * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} - * is set to the total count of matched items irrespective of pagination. - * - * Notice that setting this field to true affects the performance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2alpha.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to 100. The maximum allowed value is 1000. - * Values above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2alpha.Product|Product} or - * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} - * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} - * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} - * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} - * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.requireTotalSize - * If true and - * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is - * empty, - * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} - * is set to the total count of matched items irrespective of pagination. - * - * Notice that setting this field to true affects the performance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.retail.v2alpha.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.list_products.js - * region_tag:retail_v2alpha_generated_ProductService_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.productServiceStub && !this._terminated) { - return this.productServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json deleted file mode 100644 index 416ef1ec..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/product_service_client_config.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.ProductService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "GetProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ListProducts": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "UpdateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "DeleteProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "PurgeProducts": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportProducts": { - "timeout_millis": 300000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "SetInventory": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/product_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts deleted file mode 100644 index 5e93921a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client.ts +++ /dev/null @@ -1,1537 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/search_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './search_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2alpha - */ -export class SearchServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - searchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SearchServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SearchServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - search: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.SearchService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.searchServiceStub) { - return this.searchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.SearchService. - this.searchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.SearchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.SearchService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const searchServiceStubMethods = - ['search']; - for (const methodName of searchServiceStubMethods) { - const callPromise = this.searchServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.searchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Performs a search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is - * unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See - * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold - * The relevance threshold of the search results. - * - * Defaults to - * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, - * which means only the most relevant results are shown, and the least number - * of results are returned. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, - * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged - * and de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - search( - request?: protos.google.cloud.retail.v2alpha.ISearchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2alpha.ISearchRequest|null, - protos.google.cloud.retail.v2alpha.ISearchResponse - ]>; - search( - request: protos.google.cloud.retail.v2alpha.ISearchRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.ISearchRequest, - protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): void; - search( - request: protos.google.cloud.retail.v2alpha.ISearchRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.ISearchRequest, - protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): void; - search( - request?: protos.google.cloud.retail.v2alpha.ISearchRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.ISearchRequest, - protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.ISearchRequest, - protos.google.cloud.retail.v2alpha.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult>): - Promise<[ - protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2alpha.ISearchRequest|null, - protos.google.cloud.retail.v2alpha.ISearchResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.search(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is - * unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See - * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold - * The relevance threshold of the search results. - * - * Defaults to - * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, - * which means only the most relevant results are shown, and the least number - * of results are returned. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, - * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged - * and de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - searchStream( - request?: protos.google.cloud.retail.v2alpha.ISearchRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.createStream( - this.innerApiCalls.search as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `search`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is - * unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See - * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold - * The relevance threshold of the search results. - * - * Defaults to - * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, - * which means only the most relevant results are shown, and the least number - * of results are returned. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, - * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2alpha.Product|Product}s or - * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged - * and de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/search_service.search.js - * region_tag:retail_v2alpha_generated_SearchService_Search_async - */ - searchAsync( - request?: protos.google.cloud.retail.v2alpha.ISearchRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.asyncIterate( - this.innerApiCalls['search'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.searchServiceStub && !this._terminated) { - return this.searchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json deleted file mode 100644 index 71a5a478..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/search_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.SearchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Search": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/search_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts deleted file mode 100644 index 1df816d8..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client.ts +++ /dev/null @@ -1,1334 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/serving_config_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './serving_config_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for modifying ServingConfig. - * @class - * @memberof v2alpha - */ -export class ServingConfigServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - servingConfigServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ServingConfigServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ServingConfigServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listServingConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'servingConfigs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.ServingConfigService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.servingConfigServiceStub) { - return this.servingConfigServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.ServingConfigService. - this.servingConfigServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ServingConfigService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.ServingConfigService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const servingConfigServiceStubMethods = - ['createServingConfig', 'deleteServingConfig', 'updateServingConfig', 'getServingConfig', 'listServingConfigs', 'addControl', 'removeControl']; - for (const methodName of servingConfigServiceStubMethods) { - const callPromise = this.servingConfigServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.servingConfigServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a ServingConfig. - * - * A maximum of 100 - * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig}s are allowed in - * a {@link google.cloud.retail.v2alpha.Catalog|Catalog}, otherwise a - * FAILED_PRECONDITION error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full resource name of parent. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig - * Required. The ServingConfig to create. - * @param {string} request.servingConfigId - * Required. The ID to use for the ServingConfig, which will become the final - * component of the ServingConfig's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link 0-9|a-z}-_/. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.create_serving_config.js - * region_tag:retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async - */ - createServingConfig( - request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|undefined, {}|undefined - ]>; - createServingConfig( - request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createServingConfig(request, options, callback); - } -/** - * Deletes a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ServingConfig to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.delete_serving_config.js - * region_tag:retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async - */ - deleteServingConfig( - request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|undefined, {}|undefined - ]>; - deleteServingConfig( - request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteServingConfig(request, options, callback); - } -/** - * Updates a ServingConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig - * Required. The ServingConfig to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig} to update. The - * following are NOT supported: - * - * * {@link google.cloud.retail.v2alpha.ServingConfig.name|ServingConfig.name} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.update_serving_config.js - * region_tag:retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async - */ - updateServingConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|undefined, {}|undefined - ]>; - updateServingConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config.name': request.servingConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateServingConfig(request, options, callback); - } -/** - * Gets a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ServingConfig to get. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.get_serving_config.js - * region_tag:retail_v2alpha_generated_ServingConfigService_GetServingConfig_async - */ - getServingConfig( - request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|undefined, {}|undefined - ]>; - getServingConfig( - request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IGetServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getServingConfig(request, options, callback); - } -/** - * Enables a Control on the specified ServingConfig. - * The control is added in the last position of the list of controls - * it belongs to (e.g. if it's a facet spec control it will be applied - * in the last position of servingConfig.facetSpecIds) - * Returns a ALREADY_EXISTS error if the control has already been applied. - * Returns a FAILED_PRECONDITION error if the addition could exceed maximum - * number of control allowed for that type of control. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {string} request.controlId - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config - if id is not found a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.add_control.js - * region_tag:retail_v2alpha_generated_ServingConfigService_AddControl_async - */ - addControl( - request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|undefined, {}|undefined - ]>; - addControl( - request: protos.google.cloud.retail.v2alpha.IAddControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request: protos.google.cloud.retail.v2alpha.IAddControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IAddControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config': request.servingConfig || '', - }); - this.initialize(); - return this.innerApiCalls.addControl(request, options, callback); - } -/** - * Disables a Control on the specified ServingConfig. - * The control is removed from the ServingConfig. - * Returns a NOT_FOUND error if the Control is not enabled for the - * ServingConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {string} request.controlId - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.remove_control.js - * region_tag:retail_v2alpha_generated_ServingConfigService_RemoveControl_async - */ - removeControl( - request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|undefined, {}|undefined - ]>; - removeControl( - request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig, - protos.google.cloud.retail.v2alpha.IRemoveControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config': request.servingConfig || '', - }); - this.initialize(); - return this.innerApiCalls.removeControl(request, options, callback); - } - - /** - * Lists all ServingConfigs linked to this catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServingConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listServingConfigs( - request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig[], - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse - ]>; - listServingConfigs( - request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IServingConfig>): void; - listServingConfigs( - request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IServingConfig>): void; - listServingConfigs( - request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IServingConfig>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IServingConfig>): - Promise<[ - protos.google.cloud.retail.v2alpha.IServingConfig[], - protos.google.cloud.retail.v2alpha.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2alpha.IListServingConfigsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listServingConfigs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServingConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listServingConfigsStream( - request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listServingConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServingConfigs.createStream( - this.innerApiCalls.listServingConfigs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServingConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha/serving_config_service.list_serving_configs.js - * region_tag:retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async - */ - listServingConfigsAsync( - request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listServingConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServingConfigs.asyncIterate( - this.innerApiCalls['listServingConfigs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.servingConfigServiceStub && !this._terminated) { - return this.servingConfigServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json deleted file mode 100644 index 6489c5db..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_client_config.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.ServingConfigService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListServingConfigs": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AddControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/serving_config_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts deleted file mode 100644 index bde84f81..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client.ts +++ /dev/null @@ -1,1201 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/user_event_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './user_event_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting end user actions on the customer website. - * @class - * @memberof v2alpha - */ -export class UserEventServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - userEventServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of UserEventServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof UserEventServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const purgeUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.PurgeUserEventsResponse') as gax.protobuf.Type; - const purgeUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.PurgeMetadata') as gax.protobuf.Type; - const importUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportUserEventsResponse') as gax.protobuf.Type; - const importUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.ImportMetadata') as gax.protobuf.Type; - const rejoinUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RejoinUserEventsResponse') as gax.protobuf.Type; - const rejoinUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.RejoinUserEventsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - purgeUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), - purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), - importUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importUserEventsResponse.decode.bind(importUserEventsResponse), - importUserEventsMetadata.decode.bind(importUserEventsMetadata)), - rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), - rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.UserEventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.userEventServiceStub) { - return this.userEventServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.UserEventService. - this.userEventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.UserEventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.UserEventService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const userEventServiceStubMethods = - ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; - for (const methodName of userEventServiceStubMethods) { - const callPromise = this.userEventServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.userEventServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Writes a single user event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent - * Required. User event to write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2alpha.UserEvent}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.write_user_event.js - * region_tag:retail_v2alpha_generated_UserEventService_WriteUserEvent_async - */ - writeUserEvent( - request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|undefined, {}|undefined - ]>; - writeUserEvent( - request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IUserEvent, - protos.google.cloud.retail.v2alpha.IWriteUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.writeUserEvent(request, options, callback); - } -/** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Retail API JavaScript pixel and Google Tag - * Manager. Users should not call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {string} request.userEvent - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - * @param {string} request.uri - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - * @param {number} request.ets - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.collect_user_event.js - * region_tag:retail_v2alpha_generated_UserEventService_CollectUserEvent_async - */ - collectUserEvent( - request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|undefined, {}|undefined - ]>; - collectUserEvent( - request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2alpha.ICollectUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.collectUserEvent(request, options, callback); - } - -/** - * Deletes permanently all user events specified by the filter provided. - * Depending on the number of events specified by the filter, this operation - * could take hours or days to complete. To test a filter, use the list - * command first. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - * @param {string} request.filter - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * - * * `eventType`: Double quoted - * {@link google.cloud.retail.v2alpha.UserEvent.event_type|UserEvent.event_type} - * string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * - * Examples: - * - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * - * The filtering fields are assumed to have an implicit AND. - * @param {boolean} request.force - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async - */ - purgeUserEvents( - request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeUserEvents( - request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.purgeUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async - */ - async checkPurgeUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. `projects/1234/locations/global/catalogs/default_catalog` - * @param {google.cloud.retail.v2alpha.UserEventInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async - */ - importUserEvents( - request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importUserEvents( - request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async - */ - async checkImportUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a user event rejoin operation with latest product catalog. Events - * will not be annotated with detailed product information if product is - * missing from the catalog at the time the user event is ingested, and these - * events are stored as unjoined events with a limited usage on training and - * serving. This method can be used to start a join operation on specified - * events with latest version of product catalog. It can also be used to - * correct events joined with the wrong product catalog. A rejoin operation - * can take hours or days to complete. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async - */ - rejoinUserEvents( - request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rejoinUserEvents( - request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.rejoinUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rejoinUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js - * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async - */ - async checkRejoinUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.userEventServiceStub && !this._terminated) { - return this.userEventServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json deleted file mode 100644 index 21dfac2e..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_client_config.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.UserEventService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "WriteUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "CollectUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "PurgeUserEvents": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportUserEvents": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "RejoinUserEvents": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json b/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json deleted file mode 100644 index 3355857a..00000000 --- a/owl-bot-staging/v2alpha/src/v2alpha/user_event_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2alpha/catalog.proto", - "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", - "../../protos/google/cloud/retail/v2alpha/common.proto", - "../../protos/google/cloud/retail/v2alpha/completion_service.proto", - "../../protos/google/cloud/retail/v2alpha/control.proto", - "../../protos/google/cloud/retail/v2alpha/control_service.proto", - "../../protos/google/cloud/retail/v2alpha/export_config.proto", - "../../protos/google/cloud/retail/v2alpha/import_config.proto", - "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", - "../../protos/google/cloud/retail/v2alpha/product.proto", - "../../protos/google/cloud/retail/v2alpha/product_service.proto", - "../../protos/google/cloud/retail/v2alpha/promotion.proto", - "../../protos/google/cloud/retail/v2alpha/purge_config.proto", - "../../protos/google/cloud/retail/v2alpha/search_service.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config.proto", - "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", - "../../protos/google/cloud/retail/v2alpha/user_event.proto", - "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" -] diff --git a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 57b7c7be..00000000 --- a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const retail = require('@google-cloud/retail'); - -function main() { - const catalogServiceClient = new retail.CatalogServiceClient(); - const completionServiceClient = new retail.CompletionServiceClient(); - const controlServiceClient = new retail.ControlServiceClient(); - const predictionServiceClient = new retail.PredictionServiceClient(); - const productServiceClient = new retail.ProductServiceClient(); - const searchServiceClient = new retail.SearchServiceClient(); - const servingConfigServiceClient = new retail.ServingConfigServiceClient(); - const userEventServiceClient = new retail.UserEventServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 25eaae42..00000000 --- a/owl-bot-staging/v2alpha/system-test/fixtures/sample/src/index.ts +++ /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. ** - -import {CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient} from '@google-cloud/retail'; - -// check that the client class type name can be used -function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { - client.close(); -} -function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { - client.close(); -} -function doStuffWithControlServiceClient(client: ControlServiceClient) { - client.close(); -} -function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { - client.close(); -} -function doStuffWithProductServiceClient(client: ProductServiceClient) { - client.close(); -} -function doStuffWithSearchServiceClient(client: SearchServiceClient) { - client.close(); -} -function doStuffWithServingConfigServiceClient(client: ServingConfigServiceClient) { - client.close(); -} -function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const catalogServiceClient = new CatalogServiceClient(); - doStuffWithCatalogServiceClient(catalogServiceClient); - // check that the client instance can be created - const completionServiceClient = new CompletionServiceClient(); - doStuffWithCompletionServiceClient(completionServiceClient); - // check that the client instance can be created - const controlServiceClient = new ControlServiceClient(); - doStuffWithControlServiceClient(controlServiceClient); - // check that the client instance can be created - const predictionServiceClient = new PredictionServiceClient(); - doStuffWithPredictionServiceClient(predictionServiceClient); - // check that the client instance can be created - const productServiceClient = new ProductServiceClient(); - doStuffWithProductServiceClient(productServiceClient); - // check that the client instance can be created - const searchServiceClient = new SearchServiceClient(); - doStuffWithSearchServiceClient(searchServiceClient); - // check that the client instance can be created - const servingConfigServiceClient = new ServingConfigServiceClient(); - doStuffWithServingConfigServiceClient(servingConfigServiceClient); - // check that the client instance can be created - const userEventServiceClient = new UserEventServiceClient(); - doStuffWithUserEventServiceClient(userEventServiceClient); -} - -main(); diff --git a/owl-bot-staging/v2alpha/system-test/install.ts b/owl-bot-staging/v2alpha/system-test/install.ts deleted file mode 100644 index 8ec45222..00000000 --- a/owl-bot-staging/v2alpha/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/v2alpha/test/gapic_catalog_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts deleted file mode 100644 index 017ab407..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_catalog_service_v2alpha.ts +++ /dev/null @@ -1,1790 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as catalogserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.CatalogServiceClient', () => { - it('has servicePath', () => { - const servicePath = catalogserviceModule.v2alpha.CatalogServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = catalogserviceModule.v2alpha.CatalogServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = catalogserviceModule.v2alpha.CatalogServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - await client.initialize(); - assert(client.catalogServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.catalogServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('updateCatalog', () => { - it('invokes updateCatalog without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); - const [response] = await client.updateCatalog(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCatalog( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICatalog|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCatalog with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCatalog(request), expectedError); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCatalog(request), expectedError); - }); - }); - - describe('setDefaultBranch', () => { - it('invokes setDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.setDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setDefaultBranch( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setDefaultBranch(request), expectedError); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setDefaultBranch(request), expectedError); - }); - }); - - describe('getDefaultBranch', () => { - it('invokes getDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.getDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDefaultBranch( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDefaultBranch(request), expectedError); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDefaultBranch(request), expectedError); - }); - }); - - describe('getCompletionConfig', () => { - it('invokes getCompletionConfig without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCompletionConfig without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); - client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getCompletionConfig with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCompletionConfig(request), expectedError); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCompletionConfig with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getCompletionConfig(request), expectedError); - }); - }); - - describe('updateCompletionConfig', () => { - it('invokes updateCompletionConfig without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCompletionConfig without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompletionConfig()); - client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCompletionConfig with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCompletionConfig with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - }); - }); - - describe('getAttributesConfig', () => { - it('invokes getAttributesConfig without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAttributesConfig without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getAttributesConfig with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttributesConfig(request), expectedError); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAttributesConfig with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAttributesConfig(request), expectedError); - }); - }); - - describe('updateAttributesConfig', () => { - it('invokes updateAttributesConfig without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAttributesConfig without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateAttributesConfig with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAttributesConfig with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - }); - }); - - describe('addCatalogAttribute', () => { - it('invokes addCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.addCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - }); - }); - - describe('removeCatalogAttribute', () => { - it('invokes removeCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.removeCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - }); - }); - - describe('replaceCatalogAttribute', () => { - it('invokes replaceCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.replaceCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes replaceCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AttributesConfig()); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.replaceCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes replaceCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes replaceCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - }); - }); - - describe('listCatalogs', () => { - it('invokes listCatalogs without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); - const [response] = await client.listCatalogs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogs without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCatalogs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICatalog[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listCatalogs with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCatalogs(request), expectedError); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogsStream without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - ]; - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listCatalogsStream with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), - ]; - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; - const iterable = client.listCatalogsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCatalogsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts deleted file mode 100644 index c3aba50c..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_completion_service_v2alpha.ts +++ /dev/null @@ -1,703 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as completionserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2alpha.CompletionServiceClient', () => { - it('has servicePath', () => { - const servicePath = completionserviceModule.v2alpha.CompletionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = completionserviceModule.v2alpha.CompletionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = completionserviceModule.v2alpha.CompletionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - await client.initialize(); - assert(client.completionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.completionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery without error using callback', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes completeQuery with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery with closed client', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CompleteQueryRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.completeQuery(request), expectedError); - }); - }); - - describe('importCompletionData', () => { - it('invokes importCompletionData without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); - const [operation] = await client.importCompletionData(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData without error using callback', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importCompletionData( - request, - (err?: Error|null, - result?: LROperation|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.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importCompletionData with call error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importCompletionData(request), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData with LRO error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importCompletionData(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportCompletionDataProgress without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportCompletionDataProgress with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts deleted file mode 100644 index 4f62d30a..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_control_service_v2alpha.ts +++ /dev/null @@ -1,1108 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as controlserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.ControlServiceClient', () => { - it('has servicePath', () => { - const servicePath = controlserviceModule.v2alpha.ControlServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = controlserviceModule.v2alpha.ControlServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = controlserviceModule.v2alpha.ControlServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.controlServiceStub, undefined); - await client.initialize(); - assert(client.controlServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.controlServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.controlServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createControl', () => { - it('invokes createControl without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); - const [response] = await client.createControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createControl without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createControl with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createControl(request), expectedError); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createControl with closed client', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateControlRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createControl(request), expectedError); - }); - }); - - describe('deleteControl', () => { - it('invokes deleteControl without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); - const [response] = await client.deleteControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteControl without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteControl( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteControl with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteControl(request), expectedError); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteControl with closed client', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteControlRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteControl(request), expectedError); - }); - }); - - describe('updateControl', () => { - it('invokes updateControl without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); - const [response] = await client.updateControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateControl without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateControl with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateControl(request), expectedError); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateControl with closed client', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateControl(request), expectedError); - }); - }); - - describe('getControl', () => { - it('invokes getControl without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); - const [response] = await client.getControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getControl without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()); - client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getControl with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getControl(request), expectedError); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getControl with closed client', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetControlRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getControl(request), expectedError); - }); - }); - - describe('listControls', () => { - it('invokes listControls without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); - const [response] = await client.listControls(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listControls without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listControls( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IControl[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listControls with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listControls(request), expectedError); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listControlsStream without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - ]; - client.descriptors.page.listControls.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listControlsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Control) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listControls, request)); - assert.strictEqual( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listControlsStream with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listControls.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listControlsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Control) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listControls, request)); - assert.strictEqual( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listControls without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), - ]; - client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; - const iterable = client.listControlsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listControls with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listControlsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts deleted file mode 100644 index d449dd3b..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_prediction_service_v2alpha.ts +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as predictionserviceModule from '../src'; - -import {protobuf} 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('v2alpha.PredictionServiceClient', () => { - it('has servicePath', () => { - const servicePath = predictionserviceModule.v2alpha.PredictionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = predictionserviceModule.v2alpha.PredictionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = predictionserviceModule.v2alpha.PredictionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - await client.initialize(); - assert(client.predictionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.predictionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('predict', () => { - it('invokes predict without error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCall(expectedResponse); - const [response] = await client.predict(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict without error using callback', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.predict( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IPredictResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes predict with error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.predict(request), expectedError); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict with closed client', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PredictRequest()); - request.placement = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.predict(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts deleted file mode 100644 index ad57c1e0..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_product_service_v2alpha.ts +++ /dev/null @@ -1,2190 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as productserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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('v2alpha.ProductServiceClient', () => { - it('has servicePath', () => { - const servicePath = productserviceModule.v2alpha.ProductServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productserviceModule.v2alpha.ProductServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productserviceModule.v2alpha.ProductServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productserviceModule.v2alpha.ProductServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - await client.initialize(); - assert(client.productServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateProductRequest()); - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetProductRequest()); - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeProductsRequest()); - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importProducts', () => { - it('invokes importProducts without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProducts( - request, - (err?: Error|null, - result?: LROperation|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.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProducts with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProducts(request), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductsProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductsProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInventory', () => { - it('invokes setInventory without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInventory(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInventory( - request, - (err?: Error|null, - result?: LROperation|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.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setInventory with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInventory(request), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInventory(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkSetInventoryProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInventoryProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInventoryProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addFulfillmentPlaces', () => { - it('invokes addFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeFulfillmentPlaces', () => { - it('invokes removeFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addLocalInventories', () => { - it('invokes addLocalInventories without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.addLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addLocalInventories with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addLocalInventories(request), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeLocalInventories', () => { - it('invokes removeLocalInventories without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeLocalInventories with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeLocalInventories(request), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - 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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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.retail.v2alpha.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.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 productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.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.retail.v2alpha.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts deleted file mode 100644 index 4c28a3a6..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_search_service_v2alpha.ts +++ /dev/null @@ -1,770 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as searchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.SearchServiceClient', () => { - it('has servicePath', () => { - const servicePath = searchserviceModule.v2alpha.SearchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = searchserviceModule.v2alpha.SearchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = searchserviceModule.v2alpha.SearchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - await client.initialize(); - assert(client.searchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.searchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('search', () => { - it('invokes search without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCall(expectedResponse); - const [response] = await client.search(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes search without error using callback', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.search( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes search with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchStream without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes searchStream with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedError = new Error('expected'); - client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = []; - const iterable = client.searchAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts deleted file mode 100644 index f3a80ec9..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_serving_config_service_v2alpha.ts +++ /dev/null @@ -1,1302 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as servingconfigserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.ServingConfigServiceClient', () => { - it('has servicePath', () => { - const servicePath = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = servingconfigserviceModule.v2alpha.ServingConfigServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servingConfigServiceStub, undefined); - await client.initialize(); - assert(client.servingConfigServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.servingConfigServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servingConfigServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createServingConfig', () => { - it('invokes createServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.createServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createServingConfig(request), expectedError); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createServingConfig(request), expectedError); - }); - }); - - describe('deleteServingConfig', () => { - it('invokes deleteServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.deleteServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServingConfig( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteServingConfig(request), expectedError); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteServingConfig(request), expectedError); - }); - }); - - describe('updateServingConfig', () => { - it('invokes updateServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateServingConfig(request), expectedError); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateServingConfig(request), expectedError); - }); - }); - - describe('getServingConfig', () => { - it('invokes getServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServingConfig(request), expectedError); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.GetServingConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getServingConfig(request), expectedError); - }); - }); - - describe('addControl', () => { - it('invokes addControl without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); - const [response] = await client.addControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addControl with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addControl(request), expectedError); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addControl with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.AddControlRequest()); - request.servingConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addControl(request), expectedError); - }); - }); - - describe('removeControl', () => { - it('invokes removeControl without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); - const [response] = await client.removeControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()); - client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeControl with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeControl(request), expectedError); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeControl with closed client', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RemoveControlRequest()); - request.servingConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeControl(request), expectedError); - }); - }); - - describe('listServingConfigs', () => { - it('invokes listServingConfigs without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listServingConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServingConfigs without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServingConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IServingConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServingConfigs(request), expectedError); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServingConfigsStream without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - ]; - client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServingConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listServingConfigsStream with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServingConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServingConfigs without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.ServingConfig()), - ]; - client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = []; - const iterable = client.listServingConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServingConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts b/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts deleted file mode 100644 index 4da29c4b..00000000 --- a/owl-bot-staging/v2alpha/test/gapic_user_event_service_v2alpha.ts +++ /dev/null @@ -1,1088 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as usereventserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2alpha.UserEventServiceClient', () => { - it('has servicePath', () => { - const servicePath = usereventserviceModule.v2alpha.UserEventServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = usereventserviceModule.v2alpha.UserEventServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = usereventserviceModule.v2alpha.UserEventServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - await client.initialize(); - assert(client.userEventServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.userEventServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('writeUserEvent', () => { - it('invokes writeUserEvent without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.writeUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2alpha.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.writeUserEvent( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IUserEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes writeUserEvent with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.WriteUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.writeUserEvent(request), expectedError); - }); - }); - - describe('collectUserEvent', () => { - it('invokes collectUserEvent without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.collectUserEvent( - request, - (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes collectUserEvent with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.CollectUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.collectUserEvent(request), expectedError); - }); - }); - - describe('purgeUserEvents', () => { - it('invokes purgeUserEvents without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeUserEvents with call error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeUserEvents(request), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importUserEvents', () => { - it('invokes importUserEvents without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.importUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importUserEvents with call error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rejoinUserEvents', () => { - it('invokes rejoinUserEvents without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejoinUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejoinUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes rejoinUserEvents with call error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejoinUserEvents(request), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejoinUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRejoinUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRejoinUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2alpha/tsconfig.json b/owl-bot-staging/v2alpha/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v2alpha/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/v2alpha/webpack.config.js b/owl-bot-staging/v2alpha/webpack.config.js deleted file mode 100644 index f2c58f25..00000000 --- a/owl-bot-staging/v2alpha/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: 'CatalogService', - filename: './catalog-service.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v2beta/.eslintignore b/owl-bot-staging/v2beta/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v2beta/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v2beta/.eslintrc.json b/owl-bot-staging/v2beta/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v2beta/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v2beta/.gitignore b/owl-bot-staging/v2beta/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v2beta/.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/v2beta/.jsdoc.js b/owl-bot-staging/v2beta/.jsdoc.js deleted file mode 100644 index 19729810..00000000 --- a/owl-bot-staging/v2beta/.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/retail', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v2beta/.mocharc.js b/owl-bot-staging/v2beta/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v2beta/.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/v2beta/.prettierrc.js b/owl-bot-staging/v2beta/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v2beta/.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/v2beta/README.md b/owl-bot-staging/v2beta/README.md deleted file mode 100644 index 822c4573..00000000 --- a/owl-bot-staging/v2beta/README.md +++ /dev/null @@ -1 +0,0 @@ -Retail: Nodejs Client diff --git a/owl-bot-staging/v2beta/linkinator.config.json b/owl-bot-staging/v2beta/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v2beta/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/v2beta/package.json b/owl-bot-staging/v2beta/package.json deleted file mode 100644 index 94071ee3..00000000 --- a/owl-bot-staging/v2beta/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@google-cloud/retail", - "version": "0.1.0", - "description": "Retail client for Node.js", - "repository": "googleapis/nodejs-retail", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google retail", - "retail", - "catalog service", - "completion service", - "control service", - "prediction service", - "product service", - "search service", - "serving config service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto deleted file mode 100644 index e0b844ef..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog.proto +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/import_config.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Configures what level the product should be uploaded with regards to -// how users will be send events and how predictions will be made. -message ProductLevelConfig { - // The type of [Product][google.cloud.retail.v2beta.Product]s allowed to be - // ingested into the catalog. Acceptable values are: - // - // * `primary` (default): You can ingest - // [Product][google.cloud.retail.v2beta.Product]s of all types. When - // ingesting a [Product][google.cloud.retail.v2beta.Product], its type will - // default to - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // if unset. - // * `variant`: You can only ingest - // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s. - // This means - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] - // cannot be empty. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `variant` and - // [merchant_center_product_id_field][google.cloud.retail.v2beta.ProductLevelConfig.merchant_center_product_id_field] - // is `itemGroupId`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string ingestion_product_type = 1; - - // Which field of [Merchant Center - // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be - // imported as [Product.id][google.cloud.retail.v2beta.Product.id]. Acceptable - // values are: - // - // * `offerId` (default): Import `offerId` as the product ID. - // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail - // API will choose one item from the ones with the same `itemGroupId`, and - // use it to represent the item group. - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // If this field is `itemGroupId` and - // [ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] - // is `variant`, an INVALID_ARGUMENT error is returned. - // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) - // for more details. - string merchant_center_product_id_field = 2; -} - -// Catalog level attribute config for an attribute. For example, if customers -// want to enable/disable facet for a specific attribute. -message CatalogAttribute { - // The type of an attribute. - enum AttributeType { - // The type of the attribute is unknown. - // - // Used when type cannot be derived from attribute that is not - // [in_use][google.cloud.retail.v2beta.CatalogAttribute.in_use]. - UNKNOWN = 0; - - // Textual attribute. - TEXTUAL = 1; - - // Numerical attribute. - NUMERICAL = 2; - } - - // The status of the indexable option of a catalog attribute. - enum IndexableOption { - // Value used when unset. Defaults to - // [INDEXABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. - INDEXABLE_OPTION_UNSPECIFIED = 0; - - // Indexable option enabled for an attribute. - INDEXABLE_ENABLED = 1; - - // Indexable option disabled for an attribute. - INDEXABLE_DISABLED = 2; - } - - // The status of the dynamic facetable option of a catalog attribute. - enum DynamicFacetableOption { - // Value used when unset. Defaults to - // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. - DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; - - // Dynamic facetable option enabled for an attribute. - DYNAMIC_FACETABLE_ENABLED = 1; - - // Dynamic facetable option disabled for an attribute. - DYNAMIC_FACETABLE_DISABLED = 2; - } - - // The status of the searchable option of a catalog attribute. - enum SearchableOption { - // Value used when unset. Defaults to - // [SEARCHABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. - SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Searchable option enabled for an attribute. - SEARCHABLE_ENABLED = 1; - - // Searchable option disabled for an attribute. - SEARCHABLE_DISABLED = 2; - } - - // Required. Attribute name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Output only. Indicates whether this attribute has been used by any - // products. `True` if at least one - // [Product][google.cloud.retail.v2beta.Product] is using this attribute in - // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. - // Otherwise, this field is `False`. - // - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] can be - // pre-loaded by using [AddCatalogAttribute][], [ImportCatalogAttributes][], - // or [UpdateAttributesConfig][] APIs. This field is `False` for pre-loaded - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s. - // - // Only [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that - // are not in use by products can be deleted. - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that are - // in use by products cannot be deleted; however, their configuration - // properties will reset to default values upon removal request. - // - // After catalog changes, it takes about 10 minutes for this field to update. - bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The type of this attribute. This is derived from the attribute - // in [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. - AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values - // are indexed so that it can be filtered, faceted, or boosted in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - IndexableOption indexable_option = 5; - - // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic - // facet. Could only be DYNAMIC_FACETABLE_DISABLED if - // [CatalogAttribute.indexable_option][google.cloud.retail.v2beta.CatalogAttribute.indexable_option] - // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. - DynamicFacetableOption dynamic_facetable_option = 6; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values - // are searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values - // will not be searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], as - // there are no text values associated to numerical attributes. - SearchableOption searchable_option = 7; -} - -// Catalog level attribute config. -message AttributesConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/AttributesConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" - }; - - // Required. Immutable. The fully qualified resource name of the attribute - // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Enable attribute(s) config at catalog level. - // For example, indexable, dynamic_facetable, or searchable for each - // attribute. - // - // The key is catalog attribute's name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - // - // The maximum number of catalog attributes allowed in a request is 1000. - map catalog_attributes = 2; - - // Output only. The - // [AttributeConfigLevel][google.cloud.retail.v2beta.AttributeConfigLevel] - // used for this catalog. - AttributeConfigLevel attribute_config_level = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Catalog level autocomplete config for customers to customize autocomplete -// feature's settings. -message CompletionConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/CompletionConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" - }; - - // Required. Immutable. Fully qualified name - // `projects/*/locations/*/catalogs/*/completionConfig` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Specifies the matching order for autocomplete suggestions, e.g., a query - // consisting of 'sh' with 'out-of-order' specified would suggest "women's - // shoes", whereas a query of 'red s' with 'exact-prefix' specified would - // suggest "red shoes". Currently supported values: - // - // * 'out-of-order' - // * 'exact-prefix' - // - // Default value: 'exact-prefix'. - string matching_order = 2; - - // The maximum number of autocomplete suggestions returned per term. The - // maximum allowed max suggestions is 20. Default value is 20. If left unset - // or set to 0, then will fallback to default value. - int32 max_suggestions = 3; - - // The minimum number of characters needed to be typed in order to get - // suggestions. Default value is 2. If left unset or set to 0, then will - // fallback to default value. - int32 min_prefix_length = 4; - - // If set to true, the auto learning function is enabled. Auto learning uses - // user data to generate suggestions using ML techniques. Default value is - // false. Only after enabling auto learning can users use `cloud-retail` - // data in - // [CompleteQueryRequest][google.cloud.retail.v2beta.CompleteQueryRequest]. - bool auto_learning = 11; - - // Output only. The input config for the import of the source data that - // contains the autocomplete phrases uploaded by the customer. - CompletionDataInputConfig suggestions_input_config = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the LRO corresponding to the latest suggestion terms - // list import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_suggestions_import_operation = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The input config for the import of the source data that - // contains the / autocomplete denylist phrases uploaded by the customer. - CompletionDataInputConfig denylist_input_config = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. LRO corresponding to the latest denylist import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_denylist_import_operation = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The input config for the import of the source data that - // contains the autocomplete allowlist phrases uploaded by the customer. - CompletionDataInputConfig allowlist_input_config = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. LRO corresponding to the latest allowlist import. - // - // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to - // retrieve the latest state of the Long Running Operation. - string last_allowlist_import_operation = 10 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Represents a link between a Merchant Center account and a branch. -// Once a link is established, products from the linked merchant center account -// will be streamed to the linked branch. -message MerchantCenterLink { - // Required. The linked [Merchant center account - // id](https://developers.google.com/shopping-content/guides/accountstatuses). - // The account must be a standalone account or a sub-account of a MCA. - int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch id (e.g. 0/1/2) within this catalog that products from - // merchant_center_account_id are streamed to. When updating this field, an - // empty value will use the currently configured default branch. However, - // changing the default branch later on won't change the linked branch here. - // - // A single branch id can only have one linked merchant center account id. - string branch_id = 2; - - // String representing the destination to import for, all if left empty. - // List of possible values can be found here. - // [https://support.google.com/merchants/answer/7501026] - // List of allowed string values: - // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory - // _ads", "Free_listings", "Free_local_listings" - // NOTE: The string values are case sensitive. - repeated string destinations = 3; - - // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 - // code. List of values can be found - // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) - // under the `region` tag. If left blank no region filtering will be - // performed. - // - // Example value: `US`. - string region_code = 4; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // ISO 639-1. - // - // This specifies the language of offers in Merchant Center that will be - // accepted. If empty no language filtering will be performed. - // - // Example value: `en`. - string language_code = 5; -} - -// Configures Merchant Center linking. -// Links contained in the config will be used to sync data from a Merchant -// Center account to a Cloud Retail branch. -message MerchantCenterLinkingConfig { - // Links between Merchant Center accounts and branches. - repeated MerchantCenterLink links = 1; -} - -// The catalog configuration. -message Catalog { - option (google.api.resource) = { - type: "retail.googleapis.com/Catalog" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" - }; - - // Required. Immutable. The fully qualified resource name of the catalog. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. Immutable. The catalog display name. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Required. The product level configuration. - ProductLevelConfig product_level_config = 4 - [(google.api.field_behavior) = REQUIRED]; - - // The Merchant Center linking configuration. - // Once a link is added, the data stream from Merchant Center to Cloud Retail - // will be enabled automatically. The requester must have access to the - // merchant center account in order to make changes to this field. - MerchantCenterLinkingConfig merchant_center_linking_config = 6; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto deleted file mode 100644 index 7e27c916..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto +++ /dev/null @@ -1,478 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/catalog.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "CatalogServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for managing catalog configuration. -service CatalogService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated - // with the project. - rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*}/catalogs" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s. - rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { - option (google.api.http) = { - patch: "/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}" - body: "catalog" - }; - option (google.api.method_signature) = "catalog,update_mask"; - } - - // Set a specified branch id as default branch. API methods such as - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] - // will treat requests using "default_branch" to the actual branch id set as - // default. - // - // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as - // default, setting - // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent - // to setting - // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to - // `projects/*/locations/*/catalogs/*/branches/1`. - // - // Using multiple branches can be useful when developers would like - // to have a staging branch to test and verify for future usage. When it - // becomes ready, developers switch on the staging branch using this API while - // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` - // as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] - // to route the traffic to this staging branch. - // - // CAUTION: If you have live predict/search traffic, switching the default - // branch could potentially cause outages if the ID space of the new branch is - // very different from the old one. - // - // More specifically: - // - // * PredictionService will only return product IDs from branch {newBranch}. - // * SearchService will only return product IDs from branch {newBranch} - // (if branch is not explicitly set). - // * UserEventService will only join events with products from branch - // {newBranch}. - rpc SetDefaultBranch(SetDefaultBranchRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" - body: "*" - }; - option (google.api.method_signature) = "catalog"; - } - - // Get which branch is currently default branch set by - // [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] - // method under a specified parent catalog. - rpc GetDefaultBranch(GetDefaultBranchRequest) - returns (GetDefaultBranchResponse) { - option (google.api.http) = { - get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" - }; - option (google.api.method_signature) = "catalog"; - } - - // Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]. - rpc GetCompletionConfig(GetCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the - // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s. - rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - patch: "/v2beta/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" - body: "completion_config" - }; - option (google.api.method_signature) = "completion_config,update_mask"; - } - - // Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. - rpc GetAttributesConfig(GetAttributesConfigRequest) - returns (AttributesConfig) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. - // - // The catalog attributes in the request will be updated in the catalog, or - // inserted if they do not exist. Existing catalog attributes not included in - // the request will remain unchanged. Attributes that are assigned to - // products, but do not exist at the catalog level, are always included in the - // response. The product attribute is assigned default values for missing - // catalog attribute fields, e.g., searchable and dynamic facetable options. - rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) - returns (AttributesConfig) { - option (google.api.http) = { - patch: "/v2beta/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" - body: "attributes_config" - }; - option (google.api.method_signature) = "attributes_config,update_mask"; - } - - // Adds the specified - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to - // add already exists, an ALREADY_EXISTS error is returned. - rpc AddCatalogAttribute(AddCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" - body: "*" - }; - } - - // Removes the specified - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to - // remove does not exist, a NOT_FOUND error is returned. - rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" - body: "*" - }; - } - - // Replaces the specified - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating - // the catalog attribute with the same - // [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. - // - // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to - // replace does not exist, a NOT_FOUND error is returned. - rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" - body: "*" - }; - } -} - -// Request for -// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] -// method. -message ListCatalogsRequest { - // Required. The account resource name with an associated location. - // - // If the caller does not have permission to list - // [Catalog][google.cloud.retail.v2beta.Catalog]s under this location, - // regardless of whether or not this location exists, a PERMISSION_DENIED - // error is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of [Catalog][google.cloud.retail.v2beta.Catalog]s to return. - // If unspecified, defaults to 50. The maximum allowed value is 1000. Values - // above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 2; - - // A page token - // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token], - // received from a previous - // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; -} - -// Response for -// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] -// method. -message ListCatalogsResponse { - // All the customer's [Catalog][google.cloud.retail.v2beta.Catalog]s. - repeated Catalog catalogs = 1; - - // A token that can be sent as - // [ListCatalogsRequest.page_token][google.cloud.retail.v2beta.ListCatalogsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request for -// [CatalogService.UpdateCatalog][google.cloud.retail.v2beta.CatalogService.UpdateCatalog] -// method. -message UpdateCatalogRequest { - // Required. The [Catalog][google.cloud.retail.v2beta.Catalog] to update. - // - // If the caller does not have permission to update the - // [Catalog][google.cloud.retail.v2beta.Catalog], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // If the [Catalog][google.cloud.retail.v2beta.Catalog] to update does not - // exist, a NOT_FOUND error is returned. - Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Catalog][google.cloud.retail.v2beta.Catalog] to update. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message to set a specified branch as new default_branch. -message SetDefaultBranchRequest { - // Full resource name of the catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // The final component of the resource name of a branch. - // - // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - // error is returned. - // - // If there are no sufficient active products in the targeted branch and - // [force][google.cloud.retail.v2beta.SetDefaultBranchRequest.force] is not - // set, a FAILED_PRECONDITION error is returned. - string branch_id = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Some note on this request, this can be retrieved by - // [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch] - // before next valid default branch set occurs. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string note = 3; - - // If set to true, it permits switching to a branch with - // [branch_id][google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id] - // even if it has no sufficient active products. - bool force = 4; -} - -// Request message to show which branch is currently the default branch. -message GetDefaultBranchRequest { - // The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; -} - -// Response message of -// [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch]. -message GetDefaultBranchResponse { - // Full resource name of the branch id currently set as default branch. - string branch = 1 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // The time when this branch is set to default. - google.protobuf.Timestamp set_time = 2; - - // This corresponds to - // [SetDefaultBranchRequest.note][google.cloud.retail.v2beta.SetDefaultBranchRequest.note] - // field, when this branch was set as default. - string note = 3; -} - -// Request for -// [CatalogService.GetCompletionConfig][google.cloud.retail.v2beta.CatalogService.GetCompletionConfig] -// method. -message GetCompletionConfigRequest { - // Required. Full CompletionConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/CompletionConfig" - } - ]; -} - -// Request for -// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig] -// method. -message UpdateCompletionConfigRequest { - // Required. The - // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. - // - // If the caller does not have permission to update the - // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig], then a - // PERMISSION_DENIED error is returned. - // - // If the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to - // update does not exist, a NOT_FOUND error is returned. - CompletionConfig completion_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. - // The following are the only supported fields: - // - // * [CompletionConfig.matching_order][google.cloud.retail.v2beta.CompletionConfig.matching_order] - // * [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions] - // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2beta.CompletionConfig.min_prefix_length] - // * [CompletionConfig.auto_learning][google.cloud.retail.v2beta.CompletionConfig.auto_learning] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.GetAttributesConfig][google.cloud.retail.v2beta.CatalogService.GetAttributesConfig] -// method. -message GetAttributesConfigRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; -} - -// Request for -// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig] -// method. -message UpdateAttributesConfigRequest { - // Required. The - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. - AttributesConfig attributes_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. - // The following is the only supported field: - // - // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2beta.AttributesConfig.catalog_attributes] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute] -// method. -message AddCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute] -// method. -message RemoveCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The attribute name key of the - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove. - string key = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute] -// method. -message ReplaceCatalogAttributeRequest { - // Required. Full AttributesConfig resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - string attributes_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/AttributesConfig" - } - ]; - - // Required. The updated - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to update. - // The following are NOT supported: - // - // * [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 3; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto deleted file mode 100644 index ada7dd15..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/common.proto +++ /dev/null @@ -1,760 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// At which level we offer configuration for attributes. -enum AttributeConfigLevel { - // Value used when unset. Defaults to - // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2beta.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. - ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; - - // At this level, we honor the attribute configurations set in - // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. - PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; - - // At this level, we honor the attribute configurations set in - // [CatalogConfig.attribute_configs][]. - CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; -} - -// The type of solution. -enum SolutionType { - // Default value. - SOLUTION_TYPE_UNSPECIFIED = 0; - - // Used for Recommendations AI. - SOLUTION_TYPE_RECOMMENDATION = 1; - - // Used for Retail Search. - SOLUTION_TYPE_SEARCH = 2; -} - -// The use case of Cloud Retail Search. -enum SearchSolutionUseCase { - // The value when it's unspecified. Defaults to - // [SEARCH][]. - SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; - - // Search use case. Expects the traffic has a non-empty - // [query][google.cloud.retail.v2beta.SearchRequest.query]. - SEARCH_SOLUTION_USE_CASE_SEARCH = 1; - - // Browse use case. Expects the traffic has an empty - // [query][google.cloud.retail.v2beta.SearchRequest.query]. - SEARCH_SOLUTION_USE_CASE_BROWSE = 2; -} - -// Metadata that is used to define a condition that triggers an action. -// A valid condition must specify at least one of 'query_terms' or -// 'products_filter'. If multiple fields are specified, the condition is met if -// all the fields are satisfied e.g. if a set of query terms and product_filter -// are set, then only items matching the product_filter for requests with a -// query matching the query terms wil get boosted. -message Condition { - // Query terms that we want to match on. - message QueryTerm { - // The value of the term to match on. - // Value cannot be empty. - // Value can have at most 3 terms if specified as a partial match. Each - // space separated string is considered as one term. - // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not - // allowed for partial match. - string value = 1; - - // Whether this is supposed to be a full or partial match. - bool full_match = 2; - } - - // Used for time-dependent conditions. - // Example: Want to have rule applied for week long sale. - message TimeRange { - // Start of time range. Range is inclusive. - google.protobuf.Timestamp start_time = 1; - - // End of time range. Range is inclusive. - google.protobuf.Timestamp end_time = 2; - } - - // A list (up to 10 entries) of terms to match the query on. If not - // specified, match all queries. - // If many query terms are specified, the condition - // is matched if any of the terms is a match (i.e. using the OR operator). - repeated QueryTerm query_terms = 1; - - // Range of time(s) specifying when Condition is active. - // Condition true if any time range matches. - repeated TimeRange active_time_range = 3; -} - -// A rule is a condition-action pair -// * A condition defines when a rule is to be triggered. -// * An action specifies what occurs on that trigger. -// Currently only boost rules are supported. -// Currently only supported by the search endpoint. -message Rule { - // A boost action to apply to results matching condition specified above. - message BoostAction { - // Strength of the condition boost, which must be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 1; - - // The filter can have a max size of 5000 characters. - // An expression which specifies which products to apply an action to. - // The syntax and supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue":
- // *(id: ANY("product_1", "product_2"))
* - // *AND
* - // *(colorFamilies: ANY("Red", "Blue"))
* - string products_filter = 2; - } - - // * Rule Condition: - // - No [Condition][query_terms] provided is a global match. - // - 1 or more [Condition][query_terms] provided is combined with OR - // operator. - // * Action Input: The request query and filter that will be applied to the - // retrieved products, in addition to any filters already provided with the - // SearchRequest. The AND operator is used to combine the query's existing - // filters with the filter rule(s). NOTE: May result in 0 results when - // filters conflict. - // * Action Result: Filters the returned objects to be ONLY those that passed - // the filter. - message FilterAction { - // A filter to apply on the matching condition results. Supported features: - // - // * [filter][google.cloud.retail.v2beta.Rule.FilterAction.filter] must be - // set. - // * Filter syntax is identical to - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter]. - // See more - // details at the Retail Search - // [user guide](/retail/search/docs/filter-and-order#filter). - // * To filter products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue":
- // *(id: ANY("product_1", "product_2"))
* - // *AND
* - // *(colorFamilies: ANY("Red", "Blue"))
* - string filter = 1; - } - - // Redirects a shopper to a specific page. - // * Rule Condition: - // - Must specify [Condition][query_terms]. - // * Action Input: Request Query - // * Action Result: Redirects shopper to provided uri. - message RedirectAction { - // URL must have length equal or less than 2000 characters. - string redirect_uri = 1; - } - - // Creates a set of terms that will be treated as synonyms of each other. - // Example: synonyms of "sneakers" and "shoes". - // * "sneakers" will use a synonym of "shoes". - // * "shoes" will use a synonym of "sneakers". - message TwowaySynonymsAction { - // Defines a set of synonyms. - // Can specify up to 100 synonyms. - // Must specify at least 2 synonyms. - repeated string synonyms = 1; - } - - // Maps a set of terms to a set of synonyms. - // Set of synonyms will be treated as synonyms of each query term only. - // `query_terms` will not be treated as synonyms of each other. - // Example: "sneakers" will use a synonym of "shoes". - // "shoes" will not use a synonym of "sneakers". - message OnewaySynonymsAction { - // Terms from the search query. - // Will treat synonyms as their synonyms. - // Not themselves synonyms of the synonyms. - // Can specify up to 100 terms. - repeated string query_terms = 3; - - // Defines a set of synonyms. - // Cannot contain duplicates. - // Can specify up to 100 synonyms. - repeated string synonyms = 4; - - // Will be [deprecated = true] post migration; - repeated string oneway_terms = 2; - } - - // Prevents `query_term` from being associated with specified terms during - // search. - // Example: Don't associate "gShoe" and "cheap". - message DoNotAssociateAction { - // Terms from the search query. - // Will not consider do_not_associate_terms for search if in search query. - // Can specify up to 100 terms. - repeated string query_terms = 2; - - // Cannot contain duplicates or the query term. - // Can specify up to 100 terms. - repeated string do_not_associate_terms = 3; - - // Will be [deprecated = true] post migration; - repeated string terms = 1; - } - - // Replaces a term in the query. Multiple replacement candidates can be - // specified. All `query_terms` will be replaced with the replacement term. - // Example: Replace "gShoe" with "google shoe". - message ReplacementAction { - // Terms from the search query. - // Will be replaced by replacement term. - // Can specify up to 100 terms. - repeated string query_terms = 2; - - // Term that will be used for replacement. - string replacement_term = 3; - - // Will be [deprecated = true] post migration; - string term = 1; - } - - // Prevents a term in the query from being used in search. - // Example: Don't search for "shoddy". - message IgnoreAction { - // Terms to ignore in the search query. - repeated string ignore_terms = 1; - } - - // An action must be provided. - oneof action { - // A boost action. - BoostAction boost_action = 2; - - // Redirects a shopper to a specific page. - RedirectAction redirect_action = 3; - - // Treats specific term as a synonym with a group of terms. - // Group of terms will not be treated as synonyms with the specific term. - OnewaySynonymsAction oneway_synonyms_action = 6; - - // Prevents term from being associated with other terms. - DoNotAssociateAction do_not_associate_action = 7; - - // Replaces specific terms in the query. - ReplacementAction replacement_action = 8; - - // Ignores specific terms from query during search. - IgnoreAction ignore_action = 9; - - // Filters results. - FilterAction filter_action = 10; - - // Treats a set of terms as synonyms of one another. - TwowaySynonymsAction twoway_synonyms_action = 11; - } - - // Required. The condition that triggers the rule. - // If the condition is empty, the rule will always apply. - Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// An intended audience of the [Product][google.cloud.retail.v2beta.Product] for -// whom it's sold. -message Audience { - // The genders of the audience. Strongly encouraged to use the standard - // values: "male", "female", "unisex". - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [gender](https://support.google.com/merchants/answer/6324479). Schema.org - // property - // [Product.audience.suggestedGender](https://schema.org/suggestedGender). - repeated string genders = 1; - - // The age groups of the audience. Strongly encouraged to use the standard - // values: "newborn" (up to 3 months old), "infant" (3–12 months old), - // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically - // teens or older). - // - // At most 5 values are allowed. Each value must be a UTF-8 encoded string - // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Google Merchant Center property - // [age_group](https://support.google.com/merchants/answer/6324463). - // Schema.org property - // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and - // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). - repeated string age_groups = 2; -} - -// The color information of a [Product][google.cloud.retail.v2beta.Product]. -message ColorInfo { - // The standard color families. Strongly recommended to use the following - // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", - // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and - // "Mixed". Normally it is expected to have only 1 color family. May consider - // using single "Mixed" instead of multiple values. - // - // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string color_families = 1; - - // The color display names, which may be different from standard color family - // names, such as the color aliases used in the website frontend. Normally - // it is expected to have only 1 color. May consider using single "Mixed" - // instead of multiple values. - // - // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - repeated string colors = 2; -} - -// A custom attribute that is not explicitly modeled in -// [Product][google.cloud.retail.v2beta.Product]. -message CustomAttribute { - // The textual values of this custom attribute. For example, `["yellow", - // "green"]` when the key is "color". - // - // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be - // set. Otherwise, an INVALID_ARGUMENT error is returned. - repeated string text = 1; - - // The numerical values of this custom attribute. For example, `[2.3, 15.4]` - // when the key is "lengths_cm". - // - // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or - // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be - // set. Otherwise, an INVALID_ARGUMENT error is returned. - repeated double numbers = 2; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2beta.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // searchable by text queries in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // This field is ignored in a - // [UserEvent][google.cloud.retail.v2beta.UserEvent]. - // - // Only set if type [text][google.cloud.retail.v2beta.CustomAttribute.text] is - // set. Otherwise, a INVALID_ARGUMENT error is returned. - optional bool searchable = 3; - - // This field will only be used when - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2beta.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // indexed, so that it can be filtered, faceted or boosted in - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // This field is ignored in a - // [UserEvent][google.cloud.retail.v2beta.UserEvent]. - // - // See - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter], - // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] - // and - // [SearchRequest.boost_spec][google.cloud.retail.v2beta.SearchRequest.boost_spec] - // for more details. - optional bool indexable = 4; -} - -// Fulfillment information, such as the store IDs for in-store pickup or region -// IDs for different shipping methods. -message FulfillmentInfo { - // The fulfillment type, including commonly used types (such as pickup in - // store and same day delivery), and custom types. Customers have to map - // custom types to their display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - string type = 1; - - // The IDs for this [type][google.cloud.retail.v2beta.FulfillmentInfo.type], - // such as the store IDs for - // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2beta.FulfillmentInfo.type] - // or the region IDs for - // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2beta.FulfillmentInfo.type]. - // - // A maximum of 3000 values are allowed. Each value must be a string with a - // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such - // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string place_ids = 2; -} - -// [Product][google.cloud.retail.v2beta.Product] image. Recommendations AI and -// Retail Search do not use product images to improve prediction and search -// results. However, product images can be returned in results, and are shown in -// prediction or search previews in the console. -message Image { - // Required. URI of the image. - // - // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // Height of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 height = 2; - - // Width of the image in number of pixels. - // - // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 width = 3; -} - -// A floating point interval. -message Interval { - // The lower bound of the interval. If neither of the min fields are set, then - // the lower bound is negative infinity. - // - // This field must be not larger than - // [max][google.cloud.retail.v2beta.Interval.max]. Otherwise, an - // INVALID_ARGUMENT error is returned. - oneof min { - // Inclusive lower bound. - double minimum = 1; - - // Exclusive lower bound. - double exclusive_minimum = 2; - } - - // The upper bound of the interval. If neither of the max fields are set, then - // the upper bound is positive infinity. - // - // This field must be not smaller than - // [min][google.cloud.retail.v2beta.Interval.min]. Otherwise, an - // INVALID_ARGUMENT error is returned. - oneof max { - // Inclusive upper bound. - double maximum = 3; - - // Exclusive upper bound. - double exclusive_maximum = 4; - } -} - -// The price information of a [Product][google.cloud.retail.v2beta.Product]. -message PriceInfo { - // The price range of all - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. - message PriceRange { - // The inclusive - // [Product.pricing_info.price][google.cloud.retail.v2beta.PriceInfo.price] - // interval of all - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. - Interval price = 1; - - // The inclusive - // [Product.pricing_info.original_price][google.cloud.retail.v2beta.PriceInfo.original_price] - // internal of all - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] having the same - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. - Interval original_price = 2; - } - - // The 3-letter currency code defined in [ISO - // 4217](https://www.iso.org/iso-4217-currency-codes.html). - // - // If this field is an unrecognizable currency code, an INVALID_ARGUMENT - // error is returned. - // - // The [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s with the same - // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] - // must share the same - // [currency_code][google.cloud.retail.v2beta.PriceInfo.currency_code]. - // Otherwise, a FAILED_PRECONDITION error is returned. - string currency_code = 1; - - // Price of the product. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). Schema.org - // property [Offer.price](https://schema.org/price). - float price = 2; - - // Price of the product without any discount. If zero, by default set to be - // the [price][google.cloud.retail.v2beta.PriceInfo.price]. - float original_price = 3; - - // The costs associated with the sale of a particular product. Used for gross - // profit reporting. - // - // * Profit = [price][google.cloud.retail.v2beta.PriceInfo.price] - - // [cost][google.cloud.retail.v2beta.PriceInfo.cost] - // - // Google Merchant Center property - // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). - float cost = 4; - - // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] - // starts to be effective. This can be set as a future timestamp, and the - // [price][google.cloud.retail.v2beta.PriceInfo.price] is only used for search - // after - // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. - // If so, the - // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must - // be set and - // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is - // used before - // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. - // - // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always - // effective because it will cause additional latency during search. - google.protobuf.Timestamp price_effective_time = 5; - - // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] - // stops to be effective. The - // [price][google.cloud.retail.v2beta.PriceInfo.price] is used for search - // before - // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. - // If this field is set, the - // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must - // be set and - // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is - // used after - // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. - // - // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always - // effective because it will cause additional latency during search. - google.protobuf.Timestamp price_expire_time = 6; - - // Output only. The price range of all the child - // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s grouped together on the - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]. Only populated for - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. - // Do not set this field in API requests. - PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The rating of a [Product][google.cloud.retail.v2beta.Product]. -message Rating { - // The total number of ratings. This value is independent of the value of - // [rating_histogram][google.cloud.retail.v2beta.Rating.rating_histogram]. - // - // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is - // returned. - int32 rating_count = 1; - - // The average rating of the [Product][google.cloud.retail.v2beta.Product]. - // - // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is - // returned. - float average_rating = 2; - - // List of rating counts per rating value (index = rating - 1). The list is - // empty if there is no rating. If the list is non-empty, its size is - // always 5. Otherwise, an INVALID_ARGUMENT error is returned. - // - // For example, [41, 14, 13, 47, 303]. It means that the - // [Product][google.cloud.retail.v2beta.Product] got 41 ratings with 1 star, - // 14 ratings with 2 star, and so on. - repeated int32 rating_histogram = 3; -} - -// Information of an end user. -message UserInfo { - // Highly recommended for logged-in users. Unique identifier for logged-in - // user, such as a user name. - // - // Always use a hashed value for this ID. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string user_id = 1; - - // The end user's IP address. This field is used to extract location - // information for personalization. - // - // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 - // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This should not be set when: - // - // * setting - // [SearchRequest.user_info][google.cloud.retail.v2beta.SearchRequest.user_info]. - // * using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] - // is set. - string ip_address = 2; - - // User agent as included in the HTTP header. Required for getting - // [SearchResponse.sponsored_results][google.cloud.retail.v2beta.SearchResponse.sponsored_results]. - // - // The field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This should not be set when using the client side event reporting with - // GTM or JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] - // or if - // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] - // is set. - string user_agent = 3; - - // True if the request is made directly from the end user, in which case the - // [ip_address][google.cloud.retail.v2beta.UserInfo.ip_address] and - // [user_agent][google.cloud.retail.v2beta.UserInfo.user_agent] can be - // populated from the HTTP request. This flag should be set only if the API - // request is made directly from the end user such as a mobile app (and not if - // a gateway or a server is processing and pushing the user events). - // - // This should not be set when using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent]. - bool direct_user_request = 4; -} - -// The inventory information at a place (e.g. a store) identified -// by a place ID. -message LocalInventory { - // The place ID for the current set of inventory information. - string place_id = 1; - - // Product price and cost information. - // - // Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 2; - - // Additional local inventory attributes, for example, store name, promotion - // tags, etc. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * At most 30 attributes are allowed. - // * The key must be a UTF-8 encoded string with a length limit of 32 - // characters. - // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, - // key0LikeThis or KEY_1_LIKE_THIS. - // * The attribute values must be of the same type (text or number). - // * Only 1 value is allowed for each attribute. - // * For text values, the length limit is 256 UTF-8 characters. - // * The attribute does not support search. The `searchable` field should be - // unset or set to false. - // * The max summed total bytes of custom attribute keys and values per - // product is 5MiB. - map attributes = 3; - - // Input only. Supported fulfillment types. Valid fulfillment type values - // include commonly used types (such as pickup in store and same day - // delivery), and custom types. Customers have to map custom types to their - // display names before rendering UI. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is - // returned. - repeated string fulfillment_types = 4 - [(google.api.field_behavior) = INPUT_ONLY]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto deleted file mode 100644 index 6a1f2907..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/import_config.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "CompletionServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Auto-completion service for retail. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service CompletionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Completes the specified prefix with keyword suggestions. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { - option (google.api.http) = { - get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" - }; - } - - // Bulk import of processed completion dataset. - // - // Request processing is asynchronous. Partial updating is not supported. - // - // The operation is successfully finished only after the imported suggestions - // are indexed successfully and ready for serving. The process takes hours. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc ImportCompletionData(ImportCompletionDataRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.ImportCompletionDataResponse" - metadata_type: "google.cloud.retail.v2beta.ImportMetadata" - }; - } -} - -// Auto-complete parameters. -message CompleteQueryRequest { - // Required. Catalog for which the completion is performed. - // - // Full resource name of catalog, such as - // `projects/*/locations/global/catalogs/default_catalog`. - string catalog = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The query used to generate suggestions. - // - // The maximum number of allowed characters is 255. - string query = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required field. A unique identifier for tracking visitors. For example, - // this could be implemented with an HTTP cookie, which should be able to - // uniquely identify a visitor on a single device. This unique identifier - // should not change if the visitor logs in or out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 7; - - // The language filters applied to the output suggestions. If set, it should - // contain the language of the query. If not set, suggestions are returned - // without considering language restrictions. This is the BCP-47 language - // code, such as "en-US" or "sr-Latn". For more information, see [Tags for - // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - // number of language codes is 3. - repeated string language_codes = 3; - - // The device type context for completion suggestions. - // It is useful to apply different suggestions on different device types, e.g. - // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - // types. - // - // Supported formats: - // - // * `UNKNOWN_DEVICE_TYPE` - // - // * `DESKTOP` - // - // * `MOBILE` - // - // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - string device_type = 4; - - // Determines which dataset to use for fetching completion. "user-data" will - // use the imported dataset through - // [CompletionService.ImportCompletionData][google.cloud.retail.v2beta.CompletionService.ImportCompletionData]. - // "cloud-retail" will use the dataset generated by cloud retail based on user - // events. If leave empty, it will use the "user-data". - // - // Current supported values: - // - // * user-data - // - // * cloud-retail - // This option requires additional allowlisting. Before using cloud-retail, - // contact Cloud Retail support team first. - string dataset = 6; - - // Completion max suggestions. If left unset or set to 0, then will fallback - // to the configured value - // [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions]. - // - // The maximum allowed max suggestions is 20. If it is set higher, it will be - // capped by 20. - int32 max_suggestions = 5; -} - -// Response of the auto-complete query. -message CompleteQueryResponse { - // Resource that represents completion results. - message CompletionResult { - // The suggestion for the query. - string suggestion = 1; - - // Custom attributes for the suggestion term. - // * For "user-data", the attributes are additional custom attributes - // ingested through BigQuery. - // * For "cloud-retail", the attributes are product attributes generated - // by Cloud Retail. - map attributes = 2; - } - - // Recent search of this user. - message RecentSearchResult { - // The recent search query. - string recent_search = 1; - } - - // Results of the matching suggestions. The result list is ordered and the - // first result is top suggestion. - repeated CompletionResult completion_results = 1; - - // A unique complete token. This should be included in the - // [UserEvent.completion_detail][google.cloud.retail.v2beta.UserEvent.completion_detail] - // for search events resulting from this completion, which enables accurate - // attribution of complete model performance. - string attribution_token = 2; - - // Matched recent searches of this user. The maximum number of recent searches - // is 10. This field is a restricted feature. Contact Retail Search support - // team if you are interested in enabling it. - // - // This feature is only available when - // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2beta.CompleteQueryRequest.visitor_id] - // field is set and [UserEvent][google.cloud.retail.v2beta.UserEvent] is - // imported. The recent searches satisfy the follow rules: - // * They are ordered from latest to oldest. - // * They are matched with - // [CompleteQueryRequest.query][google.cloud.retail.v2beta.CompleteQueryRequest.query] - // case insensitively. - // * They are transformed to lower cases. - // * They are UTF-8 safe. - // - // Recent searches are deduplicated. More recent searches will be reserved - // when duplication happens. - repeated RecentSearchResult recent_search_results = 3; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto deleted file mode 100644 index e5562227..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control.proto +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/search_service.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ControlProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Configures dynamic serving time metadata that is used to pre and post -// process search/recommendation model results. -message Control { - option (google.api.resource) = { - type: "retail.googleapis.com/Control" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" - }; - - // The behavior/type of the control - // - // A behavior/type must be specified on creation. Type cannot be changed once - // specified (e.g. A Rule control will always be a Rule control.). An - // INVALID_ARGUMENT will be returned if either condition is violated. - oneof control { - // A facet specification to perform faceted search. - SearchRequest.FacetSpec facet_spec = 3; - - // A rule control - a condition-action pair. - // Enacts a set action when the condition is triggered. - // For example: Boost "gShoe" when query full matches "Running Shoes". - Rule rule = 4; - } - - // Immutable. Fully qualified name - // projects/*/locations/global/catalogs/*/controls/* - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. The human readable control display name. Used in Retail UI. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is thrown. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Output only. List of serving configuration ids that that are associated - // with this control. Note the association is managed via the ServingConfig, - // this is an output only denormalizeed view. Assumed to be in the same - // catalog. - repeated string associated_serving_config_ids = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Immutable. The solution types that the serving config is used - // for. Currently we support setting only one type of solution at creation - // time. - // - // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. - // If no solution type is provided at creation time, will default to - // SOLUTION_TYPE_SEARCH. - repeated SolutionType solution_types = 6 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto deleted file mode 100644 index 922c46f2..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/control_service.proto +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/control.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ControlServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for modifying Control. -service ControlService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a Control. - // - // If the [Control][google.cloud.retail.v2beta.Control] to create already - // exists, an ALREADY_EXISTS error is returned. - rpc CreateControl(CreateControlRequest) returns (Control) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" - body: "control" - }; - option (google.api.method_signature) = "parent,control,control_id"; - } - - // Deletes a Control. - // - // If the [Control][google.cloud.retail.v2beta.Control] to delete does not - // exist, a NOT_FOUND error is returned. - rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a Control. - // - // [Control][google.cloud.retail.v2beta.Control] cannot be set to a different - // oneof field, if so an INVALID_ARGUMENT is returned. If the - // [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a - // NOT_FOUND error is returned. - rpc UpdateControl(UpdateControlRequest) returns (Control) { - option (google.api.http) = { - patch: "/v2beta/{control.name=projects/*/locations/*/catalogs/*/controls/*}" - body: "control" - }; - option (google.api.method_signature) = "control,update_mask"; - } - - // Gets a Control. - rpc GetControl(GetControlRequest) returns (Control) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all Controls linked to this catalog. - rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Request for CreateControl method. -message CreateControlRequest { - // Required. Full resource name of parent catalog. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The Control to create. - Control control = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the Control, which will become the final - // component of the Control's resource name. - // - // This value should be 4-63 characters, and valid characters - // are /[a-z][0-9]-_/. - string control_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for UpdateControl method. -message UpdateControlRequest { - // Required. The Control to update. - Control control = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Control][google.cloud.retail.v2beta.Control] to update. The following are - // NOT supported: - // - // * [Control.name][google.cloud.retail.v2beta.Control.name] - // - // If not set or empty, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for DeleteControl method. -message DeleteControlRequest { - // Required. The resource name of the Control to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } - ]; -} - -// Request for GetControl method. -message GetControlRequest { - // Required. The resource name of the Control to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } - ]; -} - -// Request for ListControls method. -message ListControlsRequest { - // Required. The catalog resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Optional. Maximum number of results to return. If unspecified, defaults - // to 50. Max allowed value is 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListControls` call. - // Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2beta.ListControlsRequest.filter] is unset. - // * List controls that are used in a single ServingConfig: - // 'serving_config = "boosted_home_page_cvr"' - string filter = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for ListControls method. -message ListControlsResponse { - // All the Controls for a given catalog. - repeated Control controls = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto deleted file mode 100644 index 249f5011..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/export_config.proto +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ExportConfigProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Configuration of destination for Export related errors. -message ExportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage path for import errors. This must be an empty, - // existing Cloud Storage bucket. Export errors will be written to a file in - // this bucket, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Metadata related to the progress of the Export operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ExportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} - -// Response of the ExportProductsRequest. If the long running -// operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ExportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ExportErrorsConfig errors_config = 2; -} - -// Response of the ExportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ExportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ExportErrorsConfig errors_config = 2; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto deleted file mode 100644 index c1390ab0..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/import_config.proto +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/product.proto"; -import "google/cloud/retail/v2beta/user_event.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ImportConfigProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Google Cloud Storage location for input content. -// format. -message GcsSource { - // Required. Google Cloud Storage URIs to input files. URI can be up to - // 2000 characters long. URIs can match the full object path (for example, - // `gs://bucket/directory/object.json`) or a pattern matching one or more - // files, such as `gs://bucket/directory/*.json`. A request can - // contain at most 100 files, and each file can be up to 2 GB. See - // [Importing product - // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) - // for the expected file format and setup instructions. - repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON - // [Product][google.cloud.retail.v2beta.Product] per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. - // * `user_event_ga360`: Using - // https://support.google.com/analytics/answer/3437719. - // - // Supported values for control imports: - // - // * 'control' (default): One JSON - // [Control][google.cloud.retail.v2beta.Control] per line. - // - // Supported values for catalog attribute imports: - // - // * 'catalog_attribute' (default): One CSV - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] per line. - string data_schema = 2; -} - -// BigQuery source import data from. -message BigQuerySource { - // BigQuery table partition info. Leave this empty if the BigQuery table - // is not partitioned. - oneof partition { - // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - google.type.Date partition_date = 6; - } - - // The project ID (can be project # or ID) that the BigQuery source is in with - // a length limit of 128 characters. If not specified, inherits the project - // ID from the parent request. - string project_id = 5; - - // Required. The BigQuery data set to copy the data from with a length limit - // of 1,024 characters. - string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The BigQuery table to copy the data from with a length limit of - // 1,024 characters. - string table_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Intermediate Cloud Storage directory used for the import with a length - // limit of 2,000 characters. Can be specified if one wants to have the - // BigQuery export to a specific Cloud Storage directory. - string gcs_staging_dir = 3; - - // The schema to use when parsing the data from the source. - // - // Supported values for product imports: - // - // * `product` (default): One JSON - // [Product][google.cloud.retail.v2beta.Product] per line. Each product must - // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. - // * `product_merchant_center`: See [Importing catalog data from Merchant - // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). - // - // Supported values for user events imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. - // * `user_event_ga360`: - // The schema is available here: - // https://support.google.com/analytics/answer/3437719. - // * `user_event_ga4`: This feature is in private preview. Please contact the - // support team for importing Google Analytics 4 events. - // The schema is available here: - // https://support.google.com/analytics/answer/7029846. - // - // Supported values for auto-completion imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - string data_schema = 4; -} - -// The inline source for the input config for ImportProducts method. -message ProductInlineSource { - // Required. A list of products to update/create. Each product must have a - // valid [Product.id][google.cloud.retail.v2beta.Product.id]. Recommended max - // of 100 items. - repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The inline source for the input config for ImportUserEvents method. -message UserEventInlineSource { - // Required. A list of user events to import. Recommended max of 10k items. - repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Configuration of destination for Import related errors. -message ImportErrorsConfig { - // Required. Errors destination. - oneof destination { - // Google Cloud Storage prefix for import errors. This must be an empty, - // existing Cloud Storage directory. Import errors will be written to - // sharded files in this directory, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Request message for Import methods. -message ImportProductsRequest { - // Indicates how imported products are reconciled with the existing products - // created or imported before. - enum ReconciliationMode { - // Defaults to INCREMENTAL. - RECONCILIATION_MODE_UNSPECIFIED = 0; - - // Inserts new products or updates existing products. - INCREMENTAL = 1; - - // Calculates diff and replaces the entire product dataset. Existing - // products may be deleted if they are not present in the source location. - // - // Can only be set while using - // [BigQuerySource][google.cloud.retail.v2beta.BigQuerySource]. And the - // BigQuery dataset must be created in the data location "us (multiple - // regions in United States)", otherwise a PERMISSION_DENIED error is - // thrown. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - FULL = 2; - } - - // Required. - // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - // - // If no updateMask is specified, requires products.create permission. - // If updateMask is specified, requires products.update permission. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Deprecated. This field has no effect. - string request_id = 6 [deprecated = true]; - - // Required. The desired input location of the data. - ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. - ImportErrorsConfig errors_config = 3; - - // Indicates which fields in the provided imported 'products' to update. If - // not set, will by default update all fields. - google.protobuf.FieldMask update_mask = 4; - - // The mode of reconciliation between existing products and the products to be - // imported. Defaults to - // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. - ReconciliationMode reconciliation_mode = 5; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - string notification_pubsub_topic = 7; -} - -// Request message for the ImportUserEvents request. -message ImportUserEventsRequest { - // Required. `projects/1234/locations/global/catalogs/default_catalog` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - UserEventInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // The desired location of errors incurred during the Import. Cannot be set - // for inline user event imports. - ImportErrorsConfig errors_config = 3; -} - -// Request message for ImportCompletionData methods. -message ImportCompletionDataRequest { - // Required. The catalog which the suggestions dataset belongs to. - // - // Format: `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The desired input location of the data. - CompletionDataInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 3; -} - -// The input config source for products. -message ProductInputConfig { - // Required. The source of the input. - oneof source { - // The Inline source for the input content for products. - ProductInlineSource product_inline_source = 1; - - // Google Cloud Storage location for the input content. - GcsSource gcs_source = 2; - - // BigQuery input source. - BigQuerySource big_query_source = 3; - } -} - -// The input config source for user events. -message UserEventInputConfig { - // The source of the input. - oneof source { - // Required. The Inline source for the input content for UserEvents. - UserEventInlineSource user_event_inline_source = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. Google Cloud Storage location for the input content. - GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. BigQuery input source. - BigQuerySource big_query_source = 3 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// The input config source for completion data. -message CompletionDataInputConfig { - // The source of the input. - // - // Supported - // [BigQuerySource.data_schema][google.cloud.retail.v2beta.BigQuerySource.data_schema] - // values for suggestions imports: - // - // * `suggestions` (default): One JSON completion suggestion per line. - // * `denylist`: One JSON deny suggestion per line. - // * `allowlist`: One JSON allow suggestion per line. - oneof source { - // Required. BigQuery input source. - // - // Add the IAM permission "BigQuery Data Viewer" for - // cloud-retail-customer-data-access@system.gserviceaccount.com before - // using this feature otherwise an error is thrown. - BigQuerySource big_query_source = 1 - [(google.api.field_behavior) = REQUIRED]; - } -} - -// Metadata related to the progress of the Import operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ImportMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; - - // Deprecated. This field is never set. - string request_id = 5 [deprecated = true]; - - // Pub/Sub topic for receiving notification. If this field is set, - // when the import is finished, a notification will be sent to - // specified Pub/Sub topic. The message data will be JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 6; -} - -// Response of the -// [ImportProductsRequest][google.cloud.retail.v2beta.ImportProductsRequest]. If -// the long running operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportProductsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ImportErrorsConfig errors_config = 2; -} - -// Response of the ImportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ImportErrorsConfig errors_config = 2; - - // Aggregated statistics of user event import status. - UserEventImportSummary import_summary = 3; -} - -// A summary of import result. The UserEventImportSummary summarizes -// the import status for user events. -message UserEventImportSummary { - // Count of user events imported with complete existing catalog information. - int64 joined_events_count = 1; - - // Count of user events imported, but with catalog information not found - // in the imported catalog. - int64 unjoined_events_count = 2; -} - -// Response of the -// [ImportCompletionDataRequest][google.cloud.retail.v2beta.ImportCompletionDataRequest]. -// If the long running operation is done, this message is returned by the -// google.longrunning.Operations.response field if the operation is successful. -message ImportCompletionDataResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto deleted file mode 100644 index c5ec1871..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2beta/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "PredictionServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for making recommendation prediction. -service PredictionService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Makes a recommendation prediction. - rpc Predict(PredictRequest) returns (PredictResponse) { - option (google.api.http) = { - post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" - body: "*" - }; - } -} - -// Request message for Predict method. -message PredictRequest { - // Required. Full resource name of the format: - // {name=projects/*/locations/global/catalogs/default_catalog/placements/*} - // The ID of the Recommendations AI placement. Before you can request - // predictions from your model, you must create at least one placement for it. - // For more information, see [Managing - // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - // - // The full list of available placements can be seen at - // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Context about the user, what they are looking at and what action - // they took to trigger the predict request. Note that this user event detail - // won't be ingested to userEvent logs. Thus, a separate userEvent write - // request is required for event logging. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // Maximum number of results to return per page. Set this property - // to the number of prediction results needed. If zero, the service will - // choose a reasonable default. The maximum allowed value is 100. Values - // above 100 will be coerced to 100. - int32 page_size = 3; - - // The previous PredictResponse.next_page_token. - string page_token = 4; - - // Filter for restricting prediction results with a length limit of 5,000 - // characters. Accepts values for tags and the `filterOutOfStockItems` flag. - // - // * Tag expressions. Restricts predictions to products that match all of the - // specified tags. Boolean operators `OR` and `NOT` are supported if the - // expression is enclosed in parentheses, and must be separated from the - // tag values by a space. `-"tagA"` is also supported and is equivalent to - // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - // with a size limit of 1,000 characters. - // - // Note: "Recently viewed" models don't support tag filtering at the - // moment. - // - // * filterOutOfStockItems. Restricts predictions to products that do not - // have a - // stockState value of OUT_OF_STOCK. - // - // Examples: - // - // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - // * filterOutOfStockItems tag=(-"promotional") - // * filterOutOfStockItems - // - // If your filter blocks all prediction results, the API will return generic - // (unfiltered) popular products. If you only want results strictly matching - // the filters, set `strictFiltering` to True in `PredictRequest.params` to - // receive empty results instead. - // Note that the API will never return items with storageStatus of "EXPIRED" - // or "DELETED" regardless of filter choices. - string filter = 5; - - // Use validate only mode for this prediction query. If set to true, a - // dummy model will be used that returns arbitrary products. - // Note that the validate only mode should only be used for testing the API, - // or if the model is not ready. - bool validate_only = 6; - - // Additional domain specific parameters for the predictions. - // - // Allowed values: - // - // * `returnProduct`: Boolean. If set to true, the associated product - // object will be returned in the `results.metadata` field in the - // prediction response. - // * `returnScore`: Boolean. If set to true, the prediction 'score' - // corresponding to each returned product will be set in the - // `results.metadata` field in the prediction response. The given - // 'score' indicates the probability of an product being clicked/purchased - // given the user's context and history. - // * `strictFiltering`: Boolean. True by default. If set to false, the service - // will return generic (unfiltered) popular products instead of empty if - // your filter blocks all prediction results. - // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-price-reranking', 'low-price-reranking', - // 'medium-price-reranking', 'high-price-reranking'}. This gives - // request-level control and adjusts prediction results based on product - // price. - // * `diversityLevel`: String. Default empty. If set to be non-empty, then - // it needs to be one of {'no-diversity', 'low-diversity', - // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - // request-level control and adjusts prediction results based on product - // category. - map params = 7; - - // The labels applied to a resource must meet the following requirements: - // - // * Each resource can have multiple labels, up to a maximum of 64. - // * Each label must be a key-value pair. - // * Keys have a minimum length of 1 character and a maximum length of 63 - // characters, and cannot be empty. Values can be empty, and have a maximum - // length of 63 characters. - // * Keys and values can contain only lowercase letters, numeric characters, - // underscores, and dashes. All characters must use UTF-8 encoding, and - // international characters are allowed. - // * The key portion of a label must be unique. However, you can use the same - // key with multiple resources. - // * Keys must start with a lowercase letter or international character. - // - // See [Google Cloud - // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - // for more details. - map labels = 8; -} - -// Response message for predict method. -message PredictResponse { - // PredictionResult represents the recommendation prediction results. - message PredictionResult { - // ID of the recommended product - string id = 1; - - // Additional product metadata / annotations. - // - // Possible values: - // - // * `product`: JSON representation of the product. Will be set if - // `returnProduct` is set to true in `PredictRequest.params`. - // * `score`: Prediction score in double value. Will be set if - // `returnScore` is set to true in `PredictRequest.params`. - map metadata = 2; - } - - // A list of recommended products. The order represents the ranking (from the - // most relevant product to the least). - repeated PredictionResult results = 1; - - // A unique attribution token. This should be included in the - // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this - // recommendation, which enables accurate attribution of recommendation model - // performance. - string attribution_token = 2; - - // IDs of products in the request that were missing from the inventory. - repeated string missing_ids = 3; - - // True if the validateOnly property was set in the request. - bool validate_only = 4; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto deleted file mode 100644 index 4e6dfec8..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product.proto +++ /dev/null @@ -1,566 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/promotion.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; -option (google.api.resource_definition) = { - type: "retail.googleapis.com/Branch" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" -}; - -// Product captures all metadata information of items to be recommended or -// searched. -message Product { - option (google.api.resource) = { - type: "retail.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" - }; - - // The type of this product. - enum Type { - // Default value. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] - // if unset. - TYPE_UNSPECIFIED = 0; - - // The primary type. - // - // As the primary unit for predicting, indexing and search serving, a - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product] is grouped with multiple - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s. - PRIMARY = 1; - - // The variant type. - // - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s usually share some common - // attributes on the same - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s, but they have variant - // attributes like different colors, sizes and prices, etc. - VARIANT = 2; - - // The collection type. Collection products are bundled - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s or - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s that are sold together, - // such as a jewelry set with necklaces, earrings and rings, etc. - COLLECTION = 3; - } - - // Product availability. If this field is unspecified, the product is - // assumed to be in stock. - enum Availability { - // Default product availability. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK] - // if unset. - AVAILABILITY_UNSPECIFIED = 0; - - // Product in stock. - IN_STOCK = 1; - - // Product out of stock. - OUT_OF_STOCK = 2; - - // Product that is in pre-order state. - PREORDER = 3; - - // Product that is back-ordered (i.e. temporarily out of stock). - BACKORDER = 4; - } - - oneof expiration { - // The timestamp when this product becomes unavailable for - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // If it is set, the [Product][google.cloud.retail.v2beta.Product] is not - // available for - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] - // after [expire_time][google.cloud.retail.v2beta.Product.expire_time]. - // However, the product can still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // [expire_time][google.cloud.retail.v2beta.Product.expire_time] must be - // later than - // [available_time][google.cloud.retail.v2beta.Product.available_time] and - // [publish_time][google.cloud.retail.v2beta.Product.publish_time], - // otherwise an INVALID_ARGUMENT error is thrown. - // - // Corresponding properties: Google Merchant Center property - // [expiration_date](https://support.google.com/merchants/answer/6324499). - google.protobuf.Timestamp expire_time = 16; - - // Input only. The TTL (time to live) of the product. - // - // If it is set, it must be a non-negative value, and - // [expire_time][google.cloud.retail.v2beta.Product.expire_time] is set as - // current timestamp plus [ttl][google.cloud.retail.v2beta.Product.ttl]. The - // derived [expire_time][google.cloud.retail.v2beta.Product.expire_time] is - // returned in the output and [ttl][google.cloud.retail.v2beta.Product.ttl] - // is left blank when retrieving the - // [Product][google.cloud.retail.v2beta.Product]. - // - // If it is set, the product is not available for - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] - // after current timestamp plus - // [ttl][google.cloud.retail.v2beta.Product.ttl]. However, the product can - // still be retrieved by - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] - // and - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - google.protobuf.Duration ttl = 17 - [(google.api.field_behavior) = INPUT_ONLY]; - } - - // Immutable. Full resource name of the product, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. [Product][google.cloud.retail.v2beta.Product] identifier, which - // is the final component of [name][google.cloud.retail.v2beta.Product.name]. - // For example, this field is "id_1", if - // [name][google.cloud.retail.v2beta.Product.name] is - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [id](https://support.google.com/merchants/answer/6324405). Schema.org - // property [Product.sku](https://schema.org/sku). - string id = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The type of the product. Default to - // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] - // if unset. - Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; - - // Variant group identifier. Must be an - // [id][google.cloud.retail.v2beta.Product.id], with the same parent branch - // with this product. Otherwise, an error is thrown. - // - // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s, this field can only be - // empty or set to the same value as - // [id][google.cloud.retail.v2beta.Product.id]. - // - // For VARIANT [Product][google.cloud.retail.v2beta.Product]s, this field - // cannot be empty. A maximum of 2,000 products are allowed to share the same - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [item_group_id](https://support.google.com/merchants/answer/6324507). - // Schema.org property - // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). - string primary_product_id = 4; - - // The [id][google.cloud.retail.v2beta.Product.id] of the collection members - // when [type][google.cloud.retail.v2beta.Product.type] is - // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]. - // - // Non-existent product ids are allowed. - // The [type][google.cloud.retail.v2beta.Product.type] of the members must be - // either [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] or - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] otherwise - // and INVALID_ARGUMENT error is thrown. Should not set it for other types. A - // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is - // return. - repeated string collection_member_ids = 5; - - // The Global Trade Item Number (GTIN) of the product. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Corresponding properties: Google Merchant Center property - // [gtin](https://support.google.com/merchants/answer/6324461). - // Schema.org property - // [Product.isbn](https://schema.org/isbn), - // [Product.gtin8](https://schema.org/gtin8), - // [Product.gtin12](https://schema.org/gtin12), - // [Product.gtin13](https://schema.org/gtin13), or - // [Product.gtin14](https://schema.org/gtin14). - // - // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. - string gtin = 6; - - // Product categories. This field is repeated for supporting one product - // belonging to several parallel categories. Strongly recommended using the - // full path for better search / recommendation quality. - // - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // For example, if a shoes product belongs to both - // ["Shoes & Accessories" -> "Shoes"] and - // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be - // represented as: - // - // "categories": [ - // "Shoes & Accessories > Shoes", - // "Sports & Fitness > Athletic Clothing > Shoes" - // ] - // - // Must be set for - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product] otherwise an INVALID_ARGUMENT - // error is returned. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2beta.Product]. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [google_product_category][mc_google_product_category]. Schema.org property - // [Product.category] (https://schema.org/category). - // - // [mc_google_product_category]: - // https://support.google.com/merchants/answer/6324436 - repeated string categories = 7; - - // Required. Product title. - // - // This field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [title](https://support.google.com/merchants/answer/6324415). Schema.org - // property [Product.name](https://schema.org/name). - string title = 8 [(google.api.field_behavior) = REQUIRED]; - - // The brands of the product. - // - // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded - // string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [brand](https://support.google.com/merchants/answer/6324351). Schema.org - // property [Product.brand](https://schema.org/brand). - repeated string brands = 9; - - // Product description. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [description](https://support.google.com/merchants/answer/6324468). - // Schema.org property [Product.description](https://schema.org/description). - string description = 10; - - // Language of the title/description and other string attributes. Use language - // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). - // - // For product prediction, this field is ignored and the model automatically - // detects the text language. The - // [Product][google.cloud.retail.v2beta.Product] can include text in different - // languages, but duplicating [Product][google.cloud.retail.v2beta.Product]s - // to provide text in multiple languages can result in degraded model - // performance. - // - // For product search this field is in use. It defaults to "en-US" if unset. - string language_code = 11; - - // Highly encouraged. Extra product attributes to be included. For example, - // for products, this could include the store name, vendor, style, color, etc. - // These are very strong signals for recommendation model, thus we highly - // recommend providing the attributes here. - // - // Features that can take on one of a limited number of possible values. Two - // types of features can be set are: - // - // Textual features. some examples would be the brand/maker of a product, or - // country of a customer. Numerical features. Some examples would be the - // height/weight of a product, or age of a customer. - // - // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, - // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} - // }`. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * Max entries count: 200. - // * The key must be a UTF-8 encoded string with a length limit of 128 - // characters. - // * For indexable attribute, the key must match the pattern: - // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or - // `KEY_1_LIKE_THIS`. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a non-empty UTF-8 encoded string with a - // length limit of 256 characters. - // * For number attributes, at most 400 values are allowed. - map attributes = 12; - - // Custom tags associated with the product. - // - // At most 250 values are allowed per - // [Product][google.cloud.retail.v2beta.Product]. This value must be a UTF-8 - // encoded string with a length limit of 1,000 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // This tag can be used for filtering recommendation results by passing the - // tag as part of the - // [PredictRequest.filter][google.cloud.retail.v2beta.PredictRequest.filter]. - // - // Corresponding properties: Google Merchant Center property - // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). - repeated string tags = 13; - - // Product price and cost information. - // - // Corresponding properties: Google Merchant Center property - // [price](https://support.google.com/merchants/answer/6324371). - PriceInfo price_info = 14; - - // The rating of this product. - Rating rating = 15; - - // The timestamp when this [Product][google.cloud.retail.v2beta.Product] - // becomes available for - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - google.protobuf.Timestamp available_time = 18; - - // The online availability of the - // [Product][google.cloud.retail.v2beta.Product]. Default to - // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK]. - // - // Corresponding properties: Google Merchant Center property - // [availability](https://support.google.com/merchants/answer/6324448). - // Schema.org property [Offer.availability](https://schema.org/availability). - Availability availability = 19; - - // The available quantity of the item. - google.protobuf.Int32Value available_quantity = 20; - - // Fulfillment information, such as the store IDs for in-store pickup or - // region IDs for different shipping methods. - // - // All the elements must have distinct - // [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated FulfillmentInfo fulfillment_info = 21; - - // Canonical URL directly linking to the product detail page. - // - // It is strongly recommended to provide a valid uri for the product, - // otherwise the service performance could be significantly degraded. - // - // This field must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [link](https://support.google.com/merchants/answer/6324416). Schema.org - // property [Offer.url](https://schema.org/url). - string uri = 22; - - // Product images for the product. We highly recommend putting the main - // image first. - // - // A maximum of 300 images are allowed. - // - // Corresponding properties: Google Merchant Center property - // [image_link](https://support.google.com/merchants/answer/6324350). - // Schema.org property [Product.image](https://schema.org/image). - repeated Image images = 23; - - // The target group associated with a given audience (e.g. male, veterans, - // car owners, musicians, etc.) of the product. - Audience audience = 24; - - // The color of the product. - // - // Corresponding properties: Google Merchant Center property - // [color](https://support.google.com/merchants/answer/6324487). Schema.org - // property [Product.color](https://schema.org/color). - ColorInfo color_info = 25; - - // The size of the product. To represent different size systems or size types, - // consider using this format: [[[size_system:]size_type:]size_value]. - // - // For example, in "US:MENS:M", "US" represents size system; "MENS" represents - // size type; "M" represents size value. In "GIRLS:27", size system is empty; - // "GIRLS" represents size type; "27" represents size value. In "32 inches", - // both size system and size type are empty, while size value is "32 inches". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [size](https://support.google.com/merchants/answer/6324492), - // [size_type](https://support.google.com/merchants/answer/6324497), and - // [size_system](https://support.google.com/merchants/answer/6324502). - // Schema.org property [Product.size](https://schema.org/size). - repeated string sizes = 26; - - // The material of the product. For example, "leather", "wooden". - // - // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded - // string with a length limit of 200 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [material](https://support.google.com/merchants/answer/6324410). Schema.org - // property [Product.material](https://schema.org/material). - repeated string materials = 27; - - // The pattern or graphic print of the product. For example, "striped", "polka - // dot", "paisley". - // - // A maximum of 20 values are allowed per - // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org - // property [Product.pattern](https://schema.org/pattern). - repeated string patterns = 28; - - // The condition of the product. Strongly encouraged to use the standard - // values: "new", "refurbished", "used". - // - // A maximum of 1 value is allowed per - // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 - // encoded string with a length limit of 128 characters. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // Corresponding properties: Google Merchant Center property - // [condition](https://support.google.com/merchants/answer/6324469). - // Schema.org property - // [Offer.itemCondition](https://schema.org/itemCondition). - repeated string conditions = 29; - - // The promotions applied to the product. A maximum of 10 values are allowed - // per [Product][google.cloud.retail.v2beta.Product]. Only - // [Promotion.promotion_id][google.cloud.retail.v2beta.Promotion.promotion_id] - // will be used, other fields will be ignored if set. - repeated Promotion promotions = 34; - - // The timestamp when the product is published by the retailer for the first - // time, which indicates the freshness of the products. Note that this field - // is different from - // [available_time][google.cloud.retail.v2beta.Product.available_time], given - // it purely describes product freshness regardless of when it is available on - // search and recommendation. - google.protobuf.Timestamp publish_time = 33; - - // Indicates which fields in the - // [Product][google.cloud.retail.v2beta.Product]s are returned in - // [SearchResponse][google.cloud.retail.v2beta.SearchResponse]. - // - // Supported fields for all [type][google.cloud.retail.v2beta.Product.type]s: - // - // * [audience][google.cloud.retail.v2beta.Product.audience] - // * [availability][google.cloud.retail.v2beta.Product.availability] - // * [brands][google.cloud.retail.v2beta.Product.brands] - // * [color_info][google.cloud.retail.v2beta.Product.color_info] - // * [conditions][google.cloud.retail.v2beta.Product.conditions] - // * [gtin][google.cloud.retail.v2beta.Product.gtin] - // * [materials][google.cloud.retail.v2beta.Product.materials] - // * [name][google.cloud.retail.v2beta.Product.name] - // * [patterns][google.cloud.retail.v2beta.Product.patterns] - // * [price_info][google.cloud.retail.v2beta.Product.price_info] - // * [rating][google.cloud.retail.v2beta.Product.rating] - // * [sizes][google.cloud.retail.v2beta.Product.sizes] - // * [title][google.cloud.retail.v2beta.Product.title] - // * [uri][google.cloud.retail.v2beta.Product.uri] - // - // Supported fields only for - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]: - // - // * [categories][google.cloud.retail.v2beta.Product.categories] - // * [description][google.cloud.retail.v2beta.Product.description] - // * [images][google.cloud.retail.v2beta.Product.images] - // - // Supported fields only for - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]: - // - // * Only the first image in - // [images][google.cloud.retail.v2beta.Product.images] - // - // To mark [attributes][google.cloud.retail.v2beta.Product.attributes] as - // retrievable, include paths of the form "attributes.key" where "key" is the - // key of a custom attribute, as specified in - // [attributes][google.cloud.retail.v2beta.Product.attributes]. - // - // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], the - // following fields are always returned in - // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] by default: - // - // * [name][google.cloud.retail.v2beta.Product.name] - // - // For [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT], the - // following fields are always returned in by default: - // - // * [name][google.cloud.retail.v2beta.Product.name] - // * [color_info][google.cloud.retail.v2beta.Product.color_info] - // - // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Note: Returning more fields in - // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] may increase - // response payload size and serving latency. - google.protobuf.FieldMask retrievable_fields = 30; - - // Output only. Product variants grouped together on primary product which - // share similar product attributes. It's automatically grouped by - // [primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] - // for all the product variants. Only populated for - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]s. - // - // Note: This field is OUTPUT_ONLY for - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. - // Do not set this field in API requests. - repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto deleted file mode 100644 index 0ad73436..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/product_service.proto +++ /dev/null @@ -1,829 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/import_config.proto"; -import "google/cloud/retail/v2beta/product.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ProductServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for ingesting [Product][google.cloud.retail.v2beta.Product] -// information of the customer's website. -service ProductService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a [Product][google.cloud.retail.v2beta.Product]. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Gets a [Product][google.cloud.retail.v2beta.Product]. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Product][google.cloud.retail.v2beta.Product]s. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a [Product][google.cloud.retail.v2beta.Product]. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v2beta/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Deletes a [Product][google.cloud.retail.v2beta.Product]. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. - // - // Request processing may be synchronous. No partial updating is supported. - // Non-existing items are created. - // - // Note that it is possible for a subset of the - // [Product][google.cloud.retail.v2beta.Product]s to be successfully updated. - rpc ImportProducts(ImportProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.ImportProductsResponse" - metadata_type: "google.cloud.retail.v2beta.ImportMetadata" - }; - } - - // Updates inventory information for a - // [Product][google.cloud.retail.v2beta.Product] while respecting the last - // update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2beta.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, updates are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // When inventory is updated with - // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], - // the specified inventory field value(s) will overwrite any existing value(s) - // while ignoring the last update time for this field. Furthermore, the last - // update time for the specified inventory fields will be overwritten to the - // time of the - // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or - // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] - // request. - // - // If no inventory fields are set in - // [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], - // then any pre-existing inventory information for this product will be used. - // - // If no inventory fields are set in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], - // then any existing inventory information will be preserved. - // - // Pre-existing inventory information can only be updated with - // [SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], - // [AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], - // and - // [RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" - body: "*" - }; - option (google.api.method_signature) = "inventory,set_mask"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.SetInventoryResponse" - metadata_type: "google.cloud.retail.v2beta.SetInventoryMetadata" - }; - } - - // Incrementally adds place IDs to - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2beta.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the added place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata" - }; - } - - // Incrementally removes place IDs from a - // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2beta.Product] to exist before updating - // fulfillment information. If the request is valid, the update will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, the removed place IDs are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse" - metadata_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata" - }; - } - - // Updates local inventory information for a - // [Product][google.cloud.retail.v2beta.Product] at a list of places, while - // respecting the last update timestamps of each inventory field. - // - // This process is asynchronous and does not require the - // [Product][google.cloud.retail.v2beta.Product] to exist before updating - // inventory information. If the request is valid, the update will be enqueued - // and processed downstream. As a consequence, when a response is returned, - // updates are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // Local inventory information can only be modified using this method. - // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc AddLocalInventories(AddLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.AddLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2beta.AddLocalInventoriesMetadata" - }; - } - - // Remove local inventory information for a - // [Product][google.cloud.retail.v2beta.Product] at a list of places at a - // removal timestamp. - // - // This process is asynchronous. If the request is valid, the removal will be - // enqueued and processed downstream. As a consequence, when a response is - // returned, removals are not immediately manifested in the - // [Product][google.cloud.retail.v2beta.Product] queried by - // [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or - // [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // Local inventory information can only be removed using this method. - // [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // and - // [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" - body: "*" - }; - option (google.api.method_signature) = "product"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesResponse" - metadata_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata" - }; - } -} - -// Request message for [CreateProduct][] method. -message CreateProductRequest { - // Required. The parent catalog resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Required. The [Product][google.cloud.retail.v2beta.Product] to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the - // [Product][google.cloud.retail.v2beta.Product], which will become the final - // component of the [Product.name][google.cloud.retail.v2beta.Product.name]. - // - // If the caller does not have permission to create the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // This field must be unique among all - // [Product][google.cloud.retail.v2beta.Product]s with the same - // [parent][google.cloud.retail.v2beta.CreateProductRequest.parent]. - // Otherwise, an ALREADY_EXISTS error is returned. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string product_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [GetProduct][] method. -message GetProductRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // If the requested [Product][google.cloud.retail.v2beta.Product] does not - // exist, a NOT_FOUND error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for [UpdateProduct][] method. -message UpdateProductRequest { - // Required. The product to update/create. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2beta.Product] to update does not - // exist and - // [allow_missing][google.cloud.retail.v2beta.UpdateProductRequest.allow_missing] - // is not set, a NOT_FOUND error is returned. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [Product][google.cloud.retail.v2beta.Product] to update. The immutable and - // output only fields are NOT supported. If not set, all supported fields (the - // fields that are neither immutable nor output only) are updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask update_mask = 2; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, a new [Product][google.cloud.retail.v2beta.Product] will be - // created. In this situation, `update_mask` is ignored. - bool allow_missing = 3; -} - -// Request message for [DeleteProduct][] method. -message DeleteProductRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to delete the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2beta.Product] to delete does not - // exist, a NOT_FOUND error is returned. - // - // The [Product][google.cloud.retail.v2beta.Product] to delete can neither be - // a - // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2beta.Product] member nor a - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product] with more than one - // [variants][google.cloud.retail.v2beta.Product.Type.VARIANT]. Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // All inventory information for the named - // [Product][google.cloud.retail.v2beta.Product] will be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; -} - -// Request message for -// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] -// method. -message ListProductsRequest { - // Required. The parent branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use - // `default_branch` as the branch ID, to list products under the default - // branch. - // - // If the caller does not have permission to list - // [Product][google.cloud.retail.v2beta.Product]s under this branch, - // regardless of whether or not this branch exists, a PERMISSION_DENIED error - // is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. - // If unspecified, defaults to 100. The maximum allowed value is 1000. Values - // above 1000 will be coerced to 1000. - // - // If this field is negative, an INVALID_ARGUMENT error is returned. - int32 page_size = 2; - - // A page token - // [ListProductsResponse.next_page_token][google.cloud.retail.v2beta.ListProductsResponse.next_page_token], - // received from a previous - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 3; - - // A filter to apply on the list results. Supported features: - // - // * List all the products under the parent branch if - // [filter][google.cloud.retail.v2beta.ListProductsRequest.filter] is unset. - // * List - // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s sharing the same - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product]. For example: - // `primary_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2beta.Product]s bundled in a - // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2beta.Product]. - // For example: - // `collection_product_id = "some_product_id"` - // * List [Product][google.cloud.retail.v2beta.Product]s with a partibular - // type. For example: - // `type = "PRIMARY"` - // `type = "VARIANT"` - // `type = "COLLECTION"` - // - // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - // - // If the specified - // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] - // [Product][google.cloud.retail.v2beta.Product] or - // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] - // [Product][google.cloud.retail.v2beta.Product] does not exist, a NOT_FOUND - // error is returned. - string filter = 4; - - // The fields of [Product][google.cloud.retail.v2beta.Product] to return in - // the responses. If not set or empty, the following fields are returned: - // - // * [Product.name][google.cloud.retail.v2beta.Product.name] - // * [Product.id][google.cloud.retail.v2beta.Product.id] - // * [Product.title][google.cloud.retail.v2beta.Product.title] - // * [Product.uri][google.cloud.retail.v2beta.Product.uri] - // * [Product.images][google.cloud.retail.v2beta.Product.images] - // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] - // * [Product.brands][google.cloud.retail.v2beta.Product.brands] - // - // If "*" is provided, all fields are returned. - // [Product.name][google.cloud.retail.v2beta.Product.name] is always returned - // no matter what mask is set. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned. - google.protobuf.FieldMask read_mask = 5; -} - -// Response message for -// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] -// method. -message ListProductsResponse { - // The [Product][google.cloud.retail.v2beta.Product]s. - repeated Product products = 1; - - // A token that can be sent as - // [ListProductsRequest.page_token][google.cloud.retail.v2beta.ListProductsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request message for [SetInventory][] method. -message SetInventoryRequest { - // Required. The inventory information to update. The allowable fields to - // update are: - // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] - // * [Product.availability][google.cloud.retail.v2beta.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] - // The updated inventory fields must be specified in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask]. - // - // If [SetInventoryRequest.inventory.name][] is empty or invalid, an - // INVALID_ARGUMENT error is returned. - // - // If the caller does not have permission to update the - // [Product][google.cloud.retail.v2beta.Product] named in - // [Product.name][google.cloud.retail.v2beta.Product.name], regardless of - // whether or not it exists, a PERMISSION_DENIED error is returned. - // - // If the [Product][google.cloud.retail.v2beta.Product] to update does not - // have existing inventory information, the provided inventory information - // will be inserted. - // - // If the [Product][google.cloud.retail.v2beta.Product] to update has existing - // inventory information, the provided inventory information will be merged - // while respecting the last update time for each inventory field, using the - // provided or default value for - // [SetInventoryRequest.set_time][google.cloud.retail.v2beta.SetInventoryRequest.set_time]. - // - // The caller can replace place IDs for a subset of fulfillment types in the - // following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types and corresponding place IDs - // to update in [SetInventoryRequest.inventory.fulfillment_info][] - // - // The caller can clear all place IDs from a subset of fulfillment types in - // the following ways: - // - // * Adds "fulfillment_info" in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] - // * Specifies only the desired fulfillment types to clear in - // [SetInventoryRequest.inventory.fulfillment_info][] - // * Checks that only the desired fulfillment info types have empty - // [SetInventoryRequest.inventory.fulfillment_info.place_ids][] - // - // The last update time is recorded for the following inventory fields: - // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] - // * [Product.availability][google.cloud.retail.v2beta.Product.availability] - // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] - // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] - // - // If a full overwrite of inventory information while ignoring timestamps is - // needed, [UpdateProduct][] should be invoked instead. - Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided - // [Product][google.cloud.retail.v2beta.Product] to update. - // - // At least one field must be provided. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask set_mask = 2; - - // The time when the request is issued, used to prevent - // out-of-order updates on inventory fields with the last update time - // recorded. If not provided, the internal system time will be used. - google.protobuf.Timestamp set_time = 3; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] with - // name [Product.name][google.cloud.retail.v2beta.Product.name] is not found, - // the inventory update will still be processed and retained for at most 1 day - // until the [Product][google.cloud.retail.v2beta.Product] is created. If set - // to false, a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 4; -} - -// Metadata related to the progress of the SetInventory operation. -// Currently empty because there is no meaningful metadata populated from the -// [SetInventory][] method. -message SetInventoryMetadata {} - -// Response of the SetInventoryRequest. Currently empty because -// there is no meaningful response populated from the [SetInventory][] -// method. -message SetInventoryResponse {} - -// Request message for [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type], such - // as the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery" to be added for this - // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type]. - // Duplicate IDs will be automatically ignored. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - // - // If the total number of place IDs exceeds 2000 for this - // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type] after - // adding, then the update will be rejected. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, the fulfillment information will still be processed and retained - // for at most 1 day and processed once the - // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the AddFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddFulfillmentPlaces][] method. -message AddFulfillmentPlacesMetadata {} - -// Response of the AddFulfillmentPlacesRequest. Currently empty because -// there is no meaningful response populated from the [AddFulfillmentPlaces][] -// method. -message AddFulfillmentPlacesResponse {} - -// Request message for [AddLocalInventories][] method. -message AddLocalInventoriesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of inventory information at difference places. Each place - // is identified by its place ID. At most 3000 inventories are allowed per - // request. - repeated LocalInventory local_inventories = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which inventory fields in the provided list of - // [LocalInventory][google.cloud.retail.v2beta.LocalInventory] to update. The - // field is updated to the provided value. - // - // If a field is set while the place does not have a previous local inventory, - // the local inventory at that store is created. - // - // If a field is set while the value of that field is not provided, the - // original field value, if it exists, is deleted. - // - // If the mask is not set or set with empty paths, all inventory fields will - // be updated. - // - // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - // is returned and the entire update will be ignored. - google.protobuf.FieldMask add_mask = 4; - - // The time when the inventory updates are issued. Used to prevent - // out-of-order updates on local inventory fields. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp add_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, the local inventory will still be processed and retained for at - // most 1 day and processed once the - // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 6; -} - -// Metadata related to the progress of the AddLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [AddLocalInventories][] method. -message AddLocalInventoriesMetadata {} - -// Response of the [AddLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [AddLocalInventories][] -// method. -message AddLocalInventoriesResponse {} - -// Request message for [RemoveLocalInventories][] method. -message RemoveLocalInventoriesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. A list of place IDs to have their inventory deleted. - // At most 3000 place IDs are allowed per request. - repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; - - // The time when the inventory deletions are issued. Used to prevent - // out-of-order updates and deletions on local inventory fields. If not - // provided, the internal system time will be used. - google.protobuf.Timestamp remove_time = 5; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, the local inventory removal request will still be processed and - // retained for at most 1 day and processed once the - // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 3; -} - -// Metadata related to the progress of the RemoveLocalInventories operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveLocalInventories][] method. -message RemoveLocalInventoriesMetadata {} - -// Response of the [RemoveLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [RemoveLocalInventories][] -// method. -message RemoveLocalInventoriesResponse {} - -// Request message for [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesRequest { - // Required. Full resource name of - // [Product][google.cloud.retail.v2beta.Product], such as - // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - // - // If the caller does not have permission to access the - // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not - // it exists, a PERMISSION_DENIED error is returned. - string product = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } - ]; - - // Required. The fulfillment type, including commonly used types (such as - // pickup in store and same day delivery), and custom types. - // - // Supported values: - // - // * "pickup-in-store" - // * "ship-to-store" - // * "same-day-delivery" - // * "next-day-delivery" - // * "custom-type-1" - // * "custom-type-2" - // * "custom-type-3" - // * "custom-type-4" - // * "custom-type-5" - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - // - // This field directly corresponds to [Product.fulfillment_info.type][]. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The IDs for this - // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type], - // such as the store IDs for "pickup-in-store" or the region IDs for - // "same-day-delivery", to be removed for this - // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type]. - // - // At least 1 value is required, and a maximum of 2000 values are allowed. - // Each value must be a string with a length limit of 10 characters, matching - // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - // INVALID_ARGUMENT error is returned. - repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; - - // The time when the fulfillment updates are issued, used to prevent - // out-of-order updates on fulfillment information. If not provided, the - // internal system time will be used. - google.protobuf.Timestamp remove_time = 4; - - // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is - // not found, the fulfillment information will still be processed and retained - // for at most 1 day and processed once the - // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, - // a NOT_FOUND error is returned if the - // [Product][google.cloud.retail.v2beta.Product] is not found. - bool allow_missing = 5; -} - -// Metadata related to the progress of the RemoveFulfillmentPlaces operation. -// Currently empty because there is no meaningful metadata populated from the -// [RemoveFulfillmentPlaces][] method. -message RemoveFulfillmentPlacesMetadata {} - -// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there -// is no meaningful response populated from the [RemoveFulfillmentPlaces][] -// method. -message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto deleted file mode 100644 index 5346f14d..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/promotion.proto +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "PromotionProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Promotion information. -message Promotion { - // ID of the promotion. For example, "free gift". - // - // The value must be a UTF-8 encoded string with a length limit of 128 - // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, - // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Google Merchant Center property - // [promotion](https://support.google.com/merchants/answer/7050148). - string promotion_id = 1; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto deleted file mode 100644 index 5ab09aa3..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "PurgeConfigProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Metadata related to the progress of the Purge operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeMetadata {} - -// Request message for PurgeUserEvents method. -message PurgeUserEventsRequest { - // Required. The resource name of the catalog under which the events are - // created. The format is - // `projects/${projectId}/locations/global/catalogs/${catalogId}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The filter string to specify the events to be deleted with a - // length limit of 5,000 characters. Empty string filter is not allowed. The - // eligible fields for filtering are: - // - // * `eventType`: Double quoted - // [UserEvent.event_type][google.cloud.retail.v2beta.UserEvent.event_type] - // string. - // * `eventTime`: in ISO 8601 "zulu" format. - // * `visitorId`: Double quoted string. Specifying this will delete all - // events associated with a visitor. - // * `userId`: Double quoted string. Specifying this will delete all events - // associated with a user. - // - // Examples: - // - // * Deleting all events in a time range: - // `eventTime > "2012-04-23T18:25:43.511Z" - // eventTime < "2012-04-23T18:30:43.511Z"` - // * Deleting specific eventType in time range: - // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - // * Deleting all events for a specific visitor: - // `visitorId = "visitor1024"` - // - // The filtering fields are assumed to have an implicit AND. - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually perform the purge. - // If `force` is set to false, the method will return the expected purge count - // without deleting any user events. - bool force = 3; -} - -// Response of the PurgeUserEventsRequest. If the long running operation is -// successfully done, then this message is returned by the -// google.longrunning.Operations.response field. -message PurgeUserEventsResponse { - // The total count of events purged as a result of the operation. - int64 purged_events_count = 1; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto deleted file mode 100644 index b8b2156a..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/search_service.proto +++ /dev/null @@ -1,791 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/product.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "SearchServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for search. -// -// This feature is only available for users who have Retail Search enabled. -// Please enable Retail Search on Cloud Console before using this feature. -service SearchService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Performs a search. - // - // This feature is only available for users who have Retail Search enabled. - // Please enable Retail Search on Cloud Console before using this feature. - rpc Search(SearchRequest) returns (SearchResponse) { - option (google.api.http) = { - post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" - body: "*" - }; - } -} - -// Request message for -// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] -// method. -message SearchRequest { - // A facet specification to perform faceted search. - message FacetSpec { - // Specifies how a facet is computed. - message FacetKey { - // Required. Supported textual and numerical facet keys in - // [Product][google.cloud.retail.v2beta.Product] object, over which the - // facet values are computed. Facet key is case-sensitive. - // - // Allowed facet keys when - // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] - // is not specified: - // - // * textual_field = - // * "brands" - // * "categories" - // * "genders" - // * "ageGroups" - // * "availability" - // * "colorFamilies" - // * "colors" - // * "sizes" - // * "materials" - // * "patterns" - // * "conditions" - // * "attributes.key" - // * "pickupInStore" - // * "shipToStore" - // * "sameDayDelivery" - // * "nextDayDelivery" - // * "customFulfillment1" - // * "customFulfillment2" - // * "customFulfillment3" - // * "customFulfillment4" - // * "customFulfillment5" - // * "inventory(place_id,attributes.key)" - // - // * numerical_field = - // * "price" - // * "discount" - // * "rating" - // * "ratingCount" - // * "attributes.key" - // * "inventory(place_id,price)" - // * "inventory(place_id,original_price)" - // * "inventory(place_id,attributes.key)" - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Set only if values should be bucketized into intervals. Must be set - // for facets with numerical values. Must not be set for facet with text - // values. Maximum number of intervals is 30. - repeated Interval intervals = 2; - - // Only get facet for the given restricted values. For example, when using - // "pickupInStore" as key and set restricted values to - // ["store123", "store456"], only facets for "store123" and "store456" are - // returned. Only supported on textual fields and fulfillments. - // Maximum is 20. - // - // Must be set for the fulfillment facet keys: - // - // * pickupInStore - // - // * shipToStore - // - // * sameDayDelivery - // - // * nextDayDelivery - // - // * customFulfillment1 - // - // * customFulfillment2 - // - // * customFulfillment3 - // - // * customFulfillment4 - // - // * customFulfillment5 - repeated string restricted_values = 3; - - // Only get facet values that start with the given string prefix. For - // example, suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the - // "categories" facet will give only "Women > Shoe" and "Women > Dress". - // Only supported on textual fields. Maximum is 10. - repeated string prefixes = 8; - - // Only get facet values that contains the given strings. For example, - // suppose "categories" has three values "Women > Shoe", - // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the - // "categories" facet will give only "Women > Shoe" and "Men > Shoe". - // Only supported on textual fields. Maximum is 10. - repeated string contains = 9; - - // The order in which [Facet.values][] are returned. - // - // Allowed values are: - // - // * "count desc", which means order by [Facet.FacetValue.count][] - // descending. - // - // * "value desc", which means order by [Facet.FacetValue.value][] - // descending. - // Only applies to textual facets. - // - // If not set, textual values are sorted in [natural - // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical - // intervals are sorted in the order given by - // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.intervals]; - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // are sorted in the order given by - // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.restricted_values]. - string order_by = 4; - - // The query that is used to compute facet for the given facet key. - // When provided, it will override the default behavior of facet - // computation. The query syntax is the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for detail syntax and limitations. Notice that there is no limitation - // on - // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] - // when query is specified. - // - // In the response, [FacetValue.value][] will be always "1" and - // [FacetValue.count][] will be the number of results that matches the - // query. - // - // For example, you can set a customized facet for "shipToStore", - // where - // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] - // is "customizedShipToStore", and - // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] - // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". - // Then the facet will count the products that are both in stock and ship - // to store "123". - string query = 5; - } - - // Required. The facet key specification. - FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum of facet values that should be returned for this facet. If - // unspecified, defaults to 20. The maximum allowed value is 300. Values - // above 300 will be coerced to 300. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 limit = 2; - - // List of keys to exclude when faceting. - // - // By default, - // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] - // is not excluded from the filter unless it is listed in this field. - // - // For example, suppose there are 100 products with color facet "Red" and - // 200 products with color facet "Blue". A query containing the filter - // "colorFamilies:ANY("Red")" and have "colorFamilies" as - // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] - // will by default return the "Red" with count 100. - // - // If this field contains "colorFamilies", then the query returns both the - // "Red" with count 100 and "Blue" with count 200, because the - // "colorFamilies" key is now excluded from the filter. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated string excluded_filter_keys = 3; - - // Enables dynamic position for this facet. If set to true, the position of - // this facet among all facets in the response is determined by Google - // Retail Search. It will be ordered together with dynamic facets if dynamic - // facets is enabled. If set to false, the position of this facet in the - // response will be the same as in the request, and it will be ranked before - // the facets with dynamic position enable and all dynamic facets. - // - // For example, you may always want to have rating facet returned in - // the response, but it's not necessarily to always display the rating facet - // at the top. In that case, you can set enable_dynamic_position to true so - // that the position of rating facet in response will be determined by - // Google Retail Search. - // - // Another example, assuming you have the following facets in the request: - // - // * "rating", enable_dynamic_position = true - // - // * "price", enable_dynamic_position = false - // - // * "brands", enable_dynamic_position = false - // - // And also you have a dynamic facets enable, which will generate a facet - // 'gender'. Then the final order of the facets in the response can be - // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", - // "rating") depends on how Google Retail Search orders "gender" and - // "rating" facets. However, notice that "price" and "brands" will always be - // ranked at 1st and 2nd position since their enable_dynamic_position are - // false. - bool enable_dynamic_position = 4; - } - - // The specifications of dynamically generated facets. - message DynamicFacetSpec { - // Enum to control DynamicFacet mode - enum Mode { - // Default value. - MODE_UNSPECIFIED = 0; - - // Disable Dynamic Facet. - DISABLED = 1; - - // Automatic mode built by Google Retail Search. - ENABLED = 2; - } - - // Mode of the DynamicFacet feature. - // Defaults to - // [Mode.DISABLED][google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode.DISABLED] - // if it's unset. - Mode mode = 1; - } - - // Boost specification to boost certain items. - message BoostSpec { - // Boost applies to products which match a condition. - message ConditionBoostSpec { - // An expression which specifies a boost condition. The syntax and - // supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for detail syntax and limitations. - // - // Examples: - // - // * To boost products with product ID "product_1" or "product_2", and - // color - // "Red" or "Blue": - // * (id: ANY("product_1", "product_2")) AND (colorFamilies: - // ANY("Red","Blue")) - string condition = 1; - - // Strength of the condition boost, which should be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the item a big promotion. However, it does not - // necessarily mean that the boosted item will be the top result at all - // times, nor that other items will be excluded. Results could still be - // shown even when none of them matches the condition. And results that - // are significantly more relevant to the search query can still trump - // your heavily favored but irrelevant items. - // - // Setting to -1.0 gives the item a big demotion. However, results that - // are deeply relevant might still be shown. The item will have an - // upstream battle to get a fairly high ranking, but it is not blocked out - // completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 2; - } - - // Condition boost specifications. If a product matches multiple conditions - // in the specifictions, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 10. - repeated ConditionBoostSpec condition_boost_specs = 1; - - // Whether to skip boostspec validation. If this field is set to true, - // invalid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] - // will be ignored and valid - // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] - // will still be applied. - optional bool skip_boost_spec_validation = 2; - } - - // Specification to determine under which conditions query expansion should - // occur. - message QueryExpansionSpec { - // Enum describing under which condition query expansion should occur. - enum Condition { - // Unspecified query expansion condition. This defaults to - // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - CONDITION_UNSPECIFIED = 0; - - // Disabled query expansion. Only the exact search query is used, even if - // [SearchResponse.total_size][google.cloud.retail.v2beta.SearchResponse.total_size] - // is zero. - DISABLED = 1; - - // Automatic query expansion built by Google Retail Search. - AUTO = 3; - } - - // The condition under which query expansion should occur. Default to - // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - Condition condition = 1; - - // Whether to pin unexpanded results. If this field is set to true, - // unexpanded products are always at the top of the search results, followed - // by the expanded results. - bool pin_unexpanded_results = 2; - } - - // The specification for personalization. - message PersonalizationSpec { - // The personalization mode of each search request. - enum Mode { - // Default value. Defaults to - // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Let CRS decide whether to use personalization. - AUTO = 1; - - // Disable personalization. - DISABLED = 2; - } - - // Defaults to - // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. - Mode mode = 1; - } - - // The search mode of each search request. - enum SearchMode { - // Default value. In this case both product search and faceted search will - // be performed. Both [SearchResponse.SearchResult] and - // [SearchResponse.Facet] will be returned. - SEARCH_MODE_UNSPECIFIED = 0; - - // Only product search will be performed. The faceted search will be - // disabled. - // - // Only [SearchResponse.SearchResult] will be returned. - // [SearchResponse.Facet] will not be returned, even if - // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] - // or - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] - // is set. - PRODUCT_SEARCH_ONLY = 1; - - // Only faceted search will be performed. The product search will be - // disabled. - // - // When in this mode, one or both of [SearchRequest.facet_spec][] and - // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] - // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only - // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] - // will not be returned. - FACETED_SEARCH_ONLY = 2; - } - - // Required. The resource name of the search engine placement, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` - // This field is used to identify the serving configuration name and the set - // of models that will be used to make the search. - string placement = 1 [(google.api.field_behavior) = REQUIRED]; - - // The branch resource name, such as - // `projects/*/locations/global/catalogs/default_catalog/branches/0`. - // - // Use "default_branch" as the branch ID or leave this field empty, to search - // products under the default branch. - string branch = 2 [ - (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } - ]; - - // Raw search query. - string query = 3; - - // Required. A unique identifier for tracking visitors. For example, this - // could be implemented with an HTTP cookie, which should be able to uniquely - // identify a visitor on a single device. This unique identifier should not - // change if the visitor logs in or out of the website. - // - // This should be the same identifier as - // [UserEvent.visitor_id][google.cloud.retail.v2beta.UserEvent.visitor_id]. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; - - // User information. - UserInfo user_info = 5; - - // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. - // If unspecified, defaults to a reasonable value. The maximum allowed value - // is 120. Values above 120 will be coerced to 120. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 page_size = 7; - - // A page token - // [SearchResponse.next_page_token][google.cloud.retail.v2beta.SearchResponse.next_page_token], - // received from a previous - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] - // must match the call that provided the page token. Otherwise, an - // INVALID_ARGUMENT error is returned. - string page_token = 8; - - // A 0-indexed integer that specifies the current offset (that is, starting - // result location, amongst the [Product][google.cloud.retail.v2beta.Product]s - // deemed by the API as relevant) in search results. This field is only - // considered if - // [page_token][google.cloud.retail.v2beta.SearchRequest.page_token] is unset. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - int32 offset = 9; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. Filter - // expression is case-sensitive. See more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string filter = 10; - - // The default filter that is applied when a user performs a search without - // checking any filters on the search page. - // - // The filter applied to every search request when quality improvement such as - // query expansion is needed. For example, if a query does not have enough - // results, an expanded query with - // [SearchRequest.canonical_filter][google.cloud.retail.v2beta.SearchRequest.canonical_filter] - // will be returned as a supplement of the original query. This field is - // strongly recommended to achieve high search quality. - // - // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for more details about filter syntax. - string canonical_filter = 28; - - // The order in which products are returned. Products can be ordered by - // a field in an [Product][google.cloud.retail.v2beta.Product] object. Leave - // it unset if ordered by relevance. OrderBy expression is case-sensitive. See - // more details at this [user - // guide](https://cloud.google.com/retail/docs/filter-and-order#order). - // - // If this field is unrecognizable, an INVALID_ARGUMENT is returned. - string order_by = 11; - - // Facet specifications for faceted search. If empty, no facets are returned. - // - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - repeated FacetSpec facet_specs = 12; - - // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - // to enable dynamic facets. Do not set this field. - // - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; - - // Boost specification to boost certain products. See more details at this - // [user guide](https://cloud.google.com/retail/docs/boosting). - // - // Notice that if both - // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] - // and [SearchRequest.boost_spec] are set, the boost conditions from both - // places are evaluated. If a search request matches multiple boost - // conditions, the final boost score is equal to the sum of the boost scores - // from all matched boost conditions. - BoostSpec boost_spec = 13; - - // The query expansion specification that specifies the conditions under which - // query expansion will occur. See more details at this [user - // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - QueryExpansionSpec query_expansion_spec = 14; - - // The keys to fetch and rollup the matching - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s attributes, - // [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo] or - // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s attributes. - // The attributes from all the matching - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s or - // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s are merged and - // de-duplicated. Notice that rollup attributes will lead to extra query - // latency. Maximum number of keys is 30. - // - // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], a - // fulfillment type and a fulfillment ID must be provided in the format of - // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - // "pickupInStore" is fulfillment type and "store123" is the store ID. - // - // Supported keys are: - // - // * colorFamilies - // * price - // * originalPrice - // * discount - // * variantId - // * inventory(place_id,price) - // * inventory(place_id,original_price) - // * inventory(place_id,attributes.key), where key is any key in the - // [Product.inventories.attributes][] map. - // * attributes.key, where key is any key in the - // [Product.attributes][google.cloud.retail.v2beta.Product.attributes] map. - // * pickupInStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "pickup-in-store". - // * shipToStore.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "ship-to-store". - // * sameDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "same-day-delivery". - // * nextDayDelivery.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "next-day-delivery". - // * customFulfillment1.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-1". - // * customFulfillment2.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-2". - // * customFulfillment3.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-3". - // * customFulfillment4.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-4". - // * customFulfillment5.id, where id is any - // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] - // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] - // "custom-type-5". - // - // If this field is set to an invalid value other than these, an - // INVALID_ARGUMENT error is returned. - repeated string variant_rollup_keys = 17; - - // The categories associated with a category page. Required for category - // navigation queries to achieve good search quality. The format should be - // the same as - // [UserEvent.page_categories][google.cloud.retail.v2beta.UserEvent.page_categories]; - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - repeated string page_categories = 23; - - // The search mode of the search request. If not specified, a single search - // request triggers both product search and faceted search. - SearchMode search_mode = 31; - - // The specification for personalization. - PersonalizationSpec personalization_spec = 32; -} - -// Response message for -// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] -// method. -message SearchResponse { - // Represents the search results. - message SearchResult { - // [Product.id][google.cloud.retail.v2beta.Product.id] of the searched - // [Product][google.cloud.retail.v2beta.Product]. - string id = 1; - - // The product data snippet in the search response. Only - // [Product.name][google.cloud.retail.v2beta.Product.name] is guaranteed to - // be populated. - // - // [Product.variants][google.cloud.retail.v2beta.Product.variants] contains - // the product variants that match the search query. If there are multiple - // product variants matching the query, top 5 most relevant product variants - // are returned and ordered by relevancy. - // - // If relevancy can be deternmined, use - // [matching_variant_fields][google.cloud.retail.v2beta.SearchResponse.SearchResult.matching_variant_fields] - // to look up matched product variants fields. If relevancy cannot be - // determined, e.g. when searching "shoe" all products in a shoe product can - // be a match, 5 product variants are returned but order is meaningless. - Product product = 2; - - // The count of matched - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product]s. - int32 matching_variant_count = 3; - - // If a [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] matches the search query, - // this map indicates which [Product][google.cloud.retail.v2beta.Product] - // fields are matched. The key is the - // [Product.name][google.cloud.retail.v2beta.Product.name], the value is a - // field mask of the matched [Product][google.cloud.retail.v2beta.Product] - // fields. If matched attributes cannot be determined, this map will be - // empty. - // - // For example, a key "sku1" with field mask - // "products.color_info" indicates there is a match between - // "sku1" [ColorInfo][google.cloud.retail.v2beta.ColorInfo] and the query. - map matching_variant_fields = 4; - - // The rollup matching - // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2beta.Product] attributes. The key is one - // of the - // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2beta.SearchRequest.variant_rollup_keys]. - // The values are the merged and de-duplicated - // [Product][google.cloud.retail.v2beta.Product] attributes. Notice that the - // rollup values are respect filter. For example, when filtering by - // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is - // returned. - // - // For textual and numerical attributes, the rollup values is a list of - // string or double values with type - // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if - // there are two variants with colors "red" and "blue", the rollup values - // are - // - // { key: "colorFamilies" - // value { - // list_value { - // values { string_value: "red" } - // values { string_value: "blue" } - // } - // } - // } - // - // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], the - // rollup values is a double value with type - // [google.protobuf.Value][google.protobuf.Value]. For example, - // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there - // are 10 variants in this product are available in the store "store1". - map variant_rollup_values = 5; - } - - // A facet result. - message Facet { - // A facet value which contains value names and their count. - message FacetValue { - // A facet value which contains values. - oneof facet_value { - // Text value of a facet, such as "Black" for facet "colorFamilies". - string value = 1; - - // Interval value for a facet, such as [10, 20) for facet "price". - Interval interval = 2; - } - - // Number of items that have this facet value. - int64 count = 3; - } - - // The key for this facet. E.g., "colorFamilies" or "price" or - // "attributes.attr1". - string key = 1; - - // The facet values for this field. - repeated FacetValue values = 2; - - // Whether the facet is dynamically generated. - bool dynamic_facet = 3; - } - - // Information describing query expansion including whether expansion has - // occurred. - message QueryExpansionInfo { - // Bool describing whether query expansion has occurred. - bool expanded_query = 1; - - // Number of pinned results. This field will only be set when expansion - // happens and - // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] - // is set to true. - int64 pinned_result_count = 2; - } - - // A list of matched items. The order represents the ranking. - repeated SearchResult results = 1; - - // Results of facets requested by user. - repeated Facet facets = 2; - - // The estimated total count of matched items irrespective of pagination. The - // count of [results][google.cloud.retail.v2beta.SearchResponse.results] - // returned by pagination may be less than the - // [total_size][google.cloud.retail.v2beta.SearchResponse.total_size] that - // matches. - int32 total_size = 3; - - // If spell correction applies, the corrected query. Otherwise, empty. - string corrected_query = 4; - - // A unique search token. This should be included in the - // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this - // search, which enables accurate attribution of search model performance. - string attribution_token = 5; - - // A token that can be sent as - // [SearchRequest.page_token][google.cloud.retail.v2beta.SearchRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 6; - - // Query expansion information for the returned results. - QueryExpansionInfo query_expansion_info = 7; - - // The URI of a customer-defined redirect page. If redirect action is - // triggered, no search will be performed, and only - // [redirect_uri][google.cloud.retail.v2beta.SearchResponse.redirect_uri] and - // [attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] - // will be set in the response. - string redirect_uri = 10; - - // The fully qualified resource name of applied - // [controls](https://cloud.google.com/retail/docs/serving-control-rules). - repeated string applied_controls = 12; - - // The invalid - // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] - // that are not applied during serving. - repeated SearchRequest.BoostSpec.ConditionBoostSpec - invalid_condition_boost_specs = 14; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto deleted file mode 100644 index 20112e61..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/search_service.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Configures metadata that is used to generate serving time results (e.g. -// search results or recommendation predictions). -// The ServingConfig is passed in the search and predict request and together -// with the Catalog.default_branch, generates results. -message ServingConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/ServingConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" - }; - - // Immutable. Fully qualified name - // projects/*/locations/global/catalogs/*/servingConfig/* - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. The human readable serving config display name. Used in Retail - // UI. - // - // This field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // The id of the model to use at serving time. - // Currently only RecommendationModels are supported: - // https://cloud.google.com/retail/recommendations-ai/docs/create-models - // Can be changed but only to a compatible model (e.g. - // others-you-may-like CTR to others-you-may-like CVR). - // - // Required when - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string model_id = 3; - - // How much price ranking we want in serving results. - // Price reranking causes product items with a similar - // recommendation probability to be ordered by price, with the - // highest-priced items first. This setting could result in a decrease in - // click-through and conversion rates. - // Allowed values are: - // - // * 'no-price-reranking' - // * 'low-price-raranking' - // * 'medium-price-reranking' - // * 'high-price-reranking' - // - // If not specified, we choose default based on model type. Default value: - // 'no-price-reranking'. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string price_reranking_level = 4; - - // Facet specifications for faceted search. If empty, no facets are returned. - // The ids refer to the ids of [Control][google.cloud.retail.v2beta.Control] - // resources with only the Facet control set. These controls are assumed to be - // in the same [Catalog][google.cloud.retail.v2beta.Catalog] as the - // [ServingConfig][google.cloud.retail.v2beta.ServingConfig]. - // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - // is returned. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string facet_control_ids = 5; - - // The specification for dynamically generated facets. Notice that only - // textual facets can be dynamically generated. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; - - // Condition boost specifications. If a product matches multiple conditions - // in the specifications, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 100. - // - // Notice that if both - // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] - // and [SearchRequest.boost_spec] are set, the boost conditions from both - // places are evaluated. If a search request matches multiple boost - // conditions, the final boost score is equal to the sum of the boost scores - // from all matched boost conditions. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string boost_control_ids = 7; - - // Condition filter specifications. If a product matches multiple conditions - // in the specifications, filters from these specifications are all - // applied and combined via the AND operator. Maximum number of - // specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string filter_control_ids = 9; - - // Condition redirect specifications. Only the first triggered redirect action - // is applied, even if multiple apply. Maximum number of specifications is - // 1000. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string redirect_control_ids = 10; - - // Condition synonyms specifications. If multiple syonyms conditions match, - // all matching synonyms control in the list will execute. Order of controls - // in the list will not matter. Maximum number of specifications is - // 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string twoway_synonyms_control_ids = 18; - - // Condition oneway synonyms specifications. If multiple oneway synonyms - // conditions match, all matching oneway synonyms controls in the list will - // execute. Order of controls in the list will not matter. Maximum number of - // specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string oneway_synonyms_control_ids = 12; - - // Condition do not associate specifications. If multiple do not associate - // conditions match, all matching do not associate controls in the list will - // execute. - // - Order does not matter. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string do_not_associate_control_ids = 13; - - // Condition replacement specifications. - // - Applied according to the order in the list. - // - A previously replaced term can not be re-replaced. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string replacement_control_ids = 14; - - // Condition ignore specifications. If multiple ignore - // conditions match, all matching ignore controls in the list will - // execute. - // - Order does not matter. - // - Maximum number of specifications is 100. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated string ignore_control_ids = 15; - - // How much diversity to use in recommendation model results e.g. - // 'medium-diversity' or 'high-diversity'. Currently supported values: - // - // * 'no-diversity' - // * 'low-diversity' - // * 'medium-diversity' - // * 'high-diversity' - // * 'auto-diversity' - // - // If not specified, we choose default based on recommendation model - // type. Default value: 'no-diversity'. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string diversity_level = 8; - - // Whether to add additional category filters on the 'similar-items' model. - // If not specified, we enable it by default. - // Allowed values are: - // - // * 'no-category-match': No additional filtering of original results from - // the model and the customer's filters. - // * 'relaxed-category-match': Only keep results with categories that match - // at least one item categories in the PredictRequests's context item. - // * If customer also sends filters in the PredictRequest, then the results - // will satisfy both conditions (user given and category match). - // - // Can only be set if - // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] - // is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string enable_category_filter_level = 16; - - // Required. Immutable. Specifies the solution types that a serving config can - // be associated with. Currently we support setting only one type of solution. - repeated SolutionType solution_types = 19 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto deleted file mode 100644 index e56c28ac..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/serving_config.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for modifying ServingConfig. -service ServingConfigService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a ServingConfig. - // - // A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s - // are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise - // a FAILED_PRECONDITION error is returned. - rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" - body: "serving_config" - }; - option (google.api.method_signature) = - "parent,serving_config,serving_config_id"; - } - - // Deletes a ServingConfig. - // - // Returns a NotFound error if the ServingConfig does not exist. - rpc DeleteServingConfig(DeleteServingConfigRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a ServingConfig. - rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - patch: "/v2beta/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - body: "serving_config" - }; - option (google.api.method_signature) = "serving_config,update_mask"; - } - - // Gets a ServingConfig. - // - // Returns a NotFound error if the ServingConfig does not exist. - rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all ServingConfigs linked to this catalog. - rpc ListServingConfigs(ListServingConfigsRequest) - returns (ListServingConfigsResponse) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" - }; - option (google.api.method_signature) = "parent"; - } - - // Enables a Control on the specified ServingConfig. - // The control is added in the last position of the list of controls - // it belongs to (e.g. if it's a facet spec control it will be applied - // in the last position of servingConfig.facetSpecIds) - // Returns a ALREADY_EXISTS error if the control has already been applied. - // Returns a FAILED_PRECONDITION error if the addition could exceed maximum - // number of control allowed for that type of control. - rpc AddControl(AddControlRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" - body: "*" - }; - option (google.api.method_signature) = "serving_config"; - } - - // Disables a Control on the specified ServingConfig. - // The control is removed from the ServingConfig. - // Returns a NOT_FOUND error if the Control is not enabled for the - // ServingConfig. - rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" - body: "*" - }; - option (google.api.method_signature) = "serving_config"; - } -} - -// Request for CreateServingConfig method. -message CreateServingConfigRequest { - // Required. Full resource name of parent. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The ServingConfig to create. - ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the ServingConfig, which will become the final - // component of the ServingConfig's resource name. - // - // This value should be 4-63 characters, and valid characters - // are /[a-z][0-9]-_/. - string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for UpdateServingConfig method. -message UpdateServingConfigRequest { - // Required. The ServingConfig to update. - ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [ServingConfig][google.cloud.retail.v2beta.ServingConfig] to update. The - // following are NOT supported: - // - // * [ServingConfig.name][google.cloud.retail.v2beta.ServingConfig.name] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for DeleteServingConfig method. -message DeleteServingConfigRequest { - // Required. The resource name of the ServingConfig to delete. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; -} - -// Request for GetServingConfig method. -message GetServingConfigRequest { - // Required. The resource name of the ServingConfig to get. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; -} - -// Request for ListServingConfigs method. -message ListServingConfigsRequest { - // Required. The catalog resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Optional. Maximum number of results to return. If unspecified, defaults - // to 100. If a value greater than 100 is provided, at most 100 results are - // returned. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListServingConfigs` call. - // Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for ListServingConfigs method. -message ListServingConfigsResponse { - // All the ServingConfigs for a given catalog. - repeated ServingConfig serving_configs = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} - -// Request for AddControl method. -message AddControlRequest { - // Required. The source ServingConfig resource name . Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; - - // Required. The id of the control to apply. Assumed to be in the same catalog - // as the serving config - if id is not found a NOT_FOUND error is returned. - string control_id = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for RemoveControl method. -message RemoveControlRequest { - // Required. The source ServingConfig resource name . Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - } - ]; - - // Required. The id of the control to apply. Assumed to be in the same catalog - // as the serving config. - string control_id = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto deleted file mode 100644 index e2175801..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event.proto +++ /dev/null @@ -1,342 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/field_behavior.proto"; -import "google/cloud/retail/v2beta/common.proto"; -import "google/cloud/retail/v2beta/product.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// UserEvent captures all metadata information Retail API needs to know about -// how end users interact with customers' website. -message UserEvent { - // Required. User event type. Allowed values are: - // - // * `add-to-cart`: Products being added to cart. - // * `category-page-view`: Special pages such as sale or promotion pages - // viewed. - // * `detail-page-view`: Products detail page viewed. - // * `home-page-view`: Homepage viewed. - // * `promotion-offered`: Promotion is offered to a user. - // * `promotion-not-offered`: Promotion is not offered to a user. - // * `purchase-complete`: User finishing a purchase. - // * `search`: Product search. - // * `shopping-cart-page-view`: User viewing a shopping cart. - string event_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A unique identifier for tracking visitors. - // - // For example, this could be implemented with an HTTP cookie, which should be - // able to uniquely identify a visitor on a single device. This unique - // identifier should not change if the visitor log in/out of the website. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // The field should not contain PII or user-data. We recommend to use Google - // Analystics [Client - // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) - // for this field. - string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // A unique identifier for tracking a visitor session with a length limit of - // 128 bytes. A session is an aggregation of an end user behavior in a time - // span. - // - // A general guideline to populate the sesion_id: - // 1. If user has no activity for 30 min, a new session_id should be assigned. - // 2. The session_id should be unique across users, suggest use uuid or add - // visitor_id as prefix. - string session_id = 21; - - // Only required for - // [UserEventService.ImportUserEvents][google.cloud.retail.v2beta.UserEventService.ImportUserEvents] - // method. Timestamp of when the user event happened. - google.protobuf.Timestamp event_time = 3; - - // A list of identifiers for the independent experiment groups this user event - // belongs to. This is used to distinguish between user events associated with - // different experiment setups (e.g. using Retail API, using different - // recommendation models). - repeated string experiment_ids = 4; - - // Highly recommended for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. - // This field enables accurate attribution of recommendation model - // performance. - // - // The value must be a valid - // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] - // for user events that are the result of - // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. - // The value must be a valid - // [SearchResponse.attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] - // for user events that are the result of - // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. - // - // This token enables us to accurately attribute page view or purchase back to - // the event and the particular predict response containing this - // clicked/purchased product. If user clicks on product K in the - // recommendation results, pass - // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] - // as a URL parameter to product K's page. When recording events on product - // K's page, log the - // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] - // to this field. - string attribution_token = 5; - - // The main product details related to the event. - // - // This field is required for the following event types: - // - // * `add-to-cart` - // * `detail-page-view` - // * `purchase-complete` - // * `search` - // - // In a `search` event, this field represents the products returned to the end - // user on the current page (the end user may have not finished browsing the - // whole page yet). When a new page is returned to the end user, after - // pagination/filtering/ordering even for the same query, a new `search` event - // with different - // [product_details][google.cloud.retail.v2beta.UserEvent.product_details] is - // desired. The end user may have not finished browsing the whole page yet. - repeated ProductDetail product_details = 6; - - // The main auto-completion details related to the event. - // - // This field should be set for `search` event when autocomplete function is - // enabled and the user clicks a suggestion for search. - CompletionDetail completion_detail = 22; - - // Extra user event features to include in the recommendation model. - // - // If you provide custom attributes for ingested user events, also include - // them in the user events that you associate with prediction requests. Custom - // attribute formatting must be consistent between imported events and events - // provided with prediction requests. This lets the Retail API use - // those custom attributes when training models and serving predictions, which - // helps improve recommendation quality. - // - // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT - // error is returned: - // - // * The key must be a UTF-8 encoded string with a length limit of 5,000 - // characters. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 256 characters. - // * For number attributes, at most 400 values are allowed. - // - // For product recommendations, an example of extra user information is - // traffic_channel, which is how a user arrives at the site. Users can arrive - // at the site by coming to the site directly, coming through Google - // search, or in other ways. - map attributes = 7; - - // The ID or name of the associated shopping cart. This ID is used - // to associate multiple items added or present in the cart before purchase. - // - // This can only be set for `add-to-cart`, `purchase-complete`, or - // `shopping-cart-page-view` events. - string cart_id = 8; - - // A transaction represents the entire purchase transaction. - // - // Required for `purchase-complete` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - PurchaseTransaction purchase_transaction = 9; - - // The user's search query. - // - // See [SearchRequest.query][google.cloud.retail.v2beta.SearchRequest.query] - // for definition. - // - // The value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // At least one of - // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - string search_query = 10; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the products being filtered. - // - // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string filter = 16; - - // The order in which products are returned. - // - // See - // [SearchRequest.order_by][google.cloud.retail.v2beta.SearchRequest.order_by] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string order_by = 17; - - // An integer that specifies the current offset for pagination (the 0-indexed - // starting location, amongst the products deemed by the API as relevant). - // - // See [SearchRequest.offset][google.cloud.retail.v2beta.SearchRequest.offset] - // for definition. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - int32 offset = 18; - - // The categories associated with a category page. - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - // - // Required for `category-page-view` events. At least one of - // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or - // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is - // required for `search` events. Other event types should not set this field. - // Otherwise, an INVALID_ARGUMENT error is returned. - repeated string page_categories = 11; - - // User information. - UserInfo user_info = 12; - - // Complete URL (window.location.href) of the user's current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. Maximum length 5,000 - // characters. - string uri = 13; - - // The referrer URL of the current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string referrer_uri = 14; - - // A unique ID of a web page view. - // - // This should be kept the same for all user events triggered from the same - // pageview. For example, an item detail page view could trigger multiple - // events as the user is browsing the page. The `pageViewId` property should - // be kept the same for all these events so that they can be grouped together - // properly. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string page_view_id = 15; -} - -// Detailed product information associated with a user event. -message ProductDetail { - // Required. [Product][google.cloud.retail.v2beta.Product] information. - // - // Required field(s): - // - // * [Product.id][google.cloud.retail.v2beta.Product.id] - // - // Optional override field(s): - // - // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] - // - // If any supported optional fields are provided, we will treat them as a full - // override when looking up product information from the catalog. Thus, it is - // important to ensure that the overriding fields are accurate and - // complete. - // - // All other product fields are ignored and instead populated via catalog - // lookup after event ingestion. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // Quantity of the product associated with the user event. - // - // For example, this field will be 2 if two products are added to the shopping - // cart for `purchase-complete` event. Required for `add-to-cart` and - // `purchase-complete` event types. - google.protobuf.Int32Value quantity = 2; -} - -// Detailed completion information including completion attribution token and -// clicked completion info. -message CompletionDetail { - // Completion attribution token in - // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2beta.CompleteQueryResponse.attribution_token]. - string completion_attribution_token = 1; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion]. - string selected_suggestion = 2; - - // End user selected - // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion] - // position, starting from 0. - int32 selected_position = 3; -} - -// A transaction represents the entire purchase transaction. -message PurchaseTransaction { - // The transaction ID with a length limit of 128 characters. - string id = 1; - - // Required. Total non-zero revenue or grand total associated with the - // transaction. This value include shipping, tax, or other adjustments to - // total revenue that you want to include as part of your revenue - // calculations. - float revenue = 2 [(google.api.field_behavior) = REQUIRED]; - - // All the taxes associated with the transaction. - float tax = 3; - - // All the costs associated with the products. These can be manufacturing - // costs, shipping expenses not borne by the end user, or any other costs, - // such that: - // - // * Profit = - // [revenue][google.cloud.retail.v2beta.PurchaseTransaction.revenue] - - // [tax][google.cloud.retail.v2beta.PurchaseTransaction.tax] - - // [cost][google.cloud.retail.v2beta.PurchaseTransaction.cost] - float cost = 4; - - // Required. Currency code. Use three-character ISO-4217 code. - string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto b/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto deleted file mode 100644 index ab7a0b35..00000000 --- a/owl-bot-staging/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.retail.v2beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/httpbody.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2beta/import_config.proto"; -import "google/cloud/retail/v2beta/purge_config.proto"; -import "google/cloud/retail/v2beta/user_event.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; -option java_multiple_files = true; -option java_outer_classname = "UserEventServiceProto"; -option java_package = "com.google.cloud.retail.v2beta"; -option objc_class_prefix = "RETAIL"; -option php_namespace = "Google\\Cloud\\Retail\\V2beta"; -option ruby_package = "Google::Cloud::Retail::V2beta"; - -// Service for ingesting end user actions on the customer website. -service UserEventService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Writes a single user event. - rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" - body: "user_event" - }; - } - - // Writes a single user event from the browser. This uses a GET request to - // due to browser restriction of POST-ing to a 3rd party domain. - // - // This method is used only by the Retail API JavaScript pixel and Google Tag - // Manager. Users should not call this method directly. - rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" - }; - } - - // Deletes permanently all user events specified by the filter provided. - // Depending on the number of events specified by the filter, this operation - // could take hours or days to complete. To test a filter, use the list - // command first. - rpc PurgeUserEvents(PurgeUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.PurgeUserEventsResponse" - metadata_type: "google.cloud.retail.v2beta.PurgeMetadata" - }; - } - - // Bulk import of User events. Request processing might be - // synchronous. Events that already exist are skipped. - // Use this method for backfilling historical user events. - // - // Operation.response is of type ImportResponse. Note that it is - // possible for a subset of the items to be successfully inserted. - // Operation.metadata is of type ImportMetadata. - rpc ImportUserEvents(ImportUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.ImportUserEventsResponse" - metadata_type: "google.cloud.retail.v2beta.ImportMetadata" - }; - } - - // Starts a user event rejoin operation with latest product catalog. Events - // will not be annotated with detailed product information if product is - // missing from the catalog at the time the user event is ingested, and these - // events are stored as unjoined events with a limited usage on training and - // serving. This method can be used to start a join operation on specified - // events with latest version of product catalog. It can also be used to - // correct events joined with the wrong product catalog. A rejoin operation - // can take hours or days to complete. - rpc RejoinUserEvents(RejoinUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "RejoinUserEventsResponse" - metadata_type: "RejoinUserEventsMetadata" - }; - } -} - -// Request message for WriteUserEvent method. -message WriteUserEventRequest { - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. User event to write. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // Required. The parent catalog name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. URL encoded UserEvent proto with a length limit of 2,000,000 - // characters. - string user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // The URL including cgi-parameters but excluding the hash fragment with a - // length limit of 5,000 characters. This is often more useful than the - // referer URL, because many browsers only send the domain for 3rd party - // requests. - string uri = 3; - - // The event timestamp in milliseconds. This prevents browser caching of - // otherwise identical get requests. The name is abbreviated to reduce the - // payload bytes. - int64 ets = 4; -} - -// Request message for RejoinUserEvents method. -message RejoinUserEventsRequest { - // The scope of user events to be rejoined with the latest product catalog. - // If the rejoining aims at reducing number of unjoined events, set - // UserEventRejoinScope to UNJOINED_EVENTS. - // If the rejoining aims at correcting product catalog information in joined - // events, set UserEventRejoinScope to JOINED_EVENTS. - // If all events needs to be rejoined, set UserEventRejoinScope to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. - enum UserEventRejoinScope { - // Rejoin all events with the latest product catalog, including both joined - // events and unjoined events. - USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; - - // Only rejoin joined events with the latest product catalog. - JOINED_EVENTS = 1; - - // Only rejoin unjoined events with the latest product catalog. - UNJOINED_EVENTS = 2; - } - - // Required. The parent catalog resource name, such as - // `projects/1234/locations/global/catalogs/default_catalog`. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The type of the user event rejoin to define the scope and range of the user - // events to be rejoined with the latest product catalog. Defaults to - // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - // invalid integer value. - UserEventRejoinScope user_event_rejoin_scope = 2; -} - -// Response message for RejoinUserEvents method. -message RejoinUserEventsResponse { - // Number of user events that were joined with latest product catalog. - int64 rejoined_user_events_count = 1; -} - -// Metadata for RejoinUserEvents method. -message RejoinUserEventsMetadata {} diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js deleted file mode 100644 index 553e7103..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(attributesConfig, catalogAttribute) { - // [START retail_v2beta_generated_CatalogService_AddCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The - * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to add. - */ - // const catalogAttribute = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callAddCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - catalogAttribute, - }; - - // Run request - const response = await retailClient.addCatalogAttribute(request); - console.log(response); - } - - callAddCatalogAttribute(); - // [END retail_v2beta_generated_CatalogService_AddCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js deleted file mode 100644 index b6c393bd..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_CatalogService_GetAttributesConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const name = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetAttributesConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getAttributesConfig(request); - console.log(response); - } - - callGetAttributesConfig(); - // [END retail_v2beta_generated_CatalogService_GetAttributesConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js deleted file mode 100644 index 886e118a..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_CatalogService_GetCompletionConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full CompletionConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - */ - // const name = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetCompletionConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getCompletionConfig(request); - console.log(response); - } - - callGetCompletionConfig(); - // [END retail_v2beta_generated_CatalogService_GetCompletionConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js deleted file mode 100644 index 11ab8856..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2beta_generated_CatalogService_GetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callGetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.getDefaultBranch(request); - console.log(response); - } - - callGetDefaultBranch(); - // [END retail_v2beta_generated_CatalogService_GetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js deleted file mode 100644 index a72872cb..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2beta_generated_CatalogService_ListCatalogs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The account resource name with an associated location. - * If the caller does not have permission to list - * Catalog google.cloud.retail.v2beta.Catalog s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Catalog google.cloud.retail.v2beta.Catalog s to return. - * If unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListCatalogsResponse.next_page_token google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token, - * received from a previous - * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callListCatalogs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listCatalogsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCatalogs(); - // [END retail_v2beta_generated_CatalogService_ListCatalogs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js deleted file mode 100644 index b6d4473a..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(attributesConfig, key) { - // [START retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The attribute name key of the - * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to remove. - */ - // const key = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callRemoveCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - key, - }; - - // Run request - const response = await retailClient.removeCatalogAttribute(request); - console.log(response); - } - - callRemoveCatalogAttribute(); - // [END retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js deleted file mode 100644 index 42548549..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.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(attributesConfig, catalogAttribute) { - // [START retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - */ - // const attributesConfig = 'abc123' - /** - * Required. The updated - * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute. - */ - // const catalogAttribute = {} - /** - * Indicates which fields in the provided - * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to update. - * The following are NOT supported: - * * CatalogAttribute.key google.cloud.retail.v2beta.CatalogAttribute.key - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callReplaceCatalogAttribute() { - // Construct request - const request = { - attributesConfig, - catalogAttribute, - }; - - // Run request - const response = await retailClient.replaceCatalogAttribute(request); - console.log(response); - } - - callReplaceCatalogAttribute(); - // [END retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js deleted file mode 100644 index 11f667df..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START retail_v2beta_generated_CatalogService_SetDefaultBranch_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * The final component of the resource name of a branch. - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * If there are no sufficient active products in the targeted branch and - * force google.cloud.retail.v2beta.SetDefaultBranchRequest.force is not - * set, a FAILED_PRECONDITION error is returned. - */ - // const branchId = 'abc123' - /** - * Some note on this request, this can be retrieved by - * CatalogService.GetDefaultBranch google.cloud.retail.v2beta.CatalogService.GetDefaultBranch - * before next valid default branch set occurs. - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const note = 'abc123' - /** - * If set to true, it permits switching to a branch with - * branch_id google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id - * even if it has no sufficient active products. - */ - // const force = true - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callSetDefaultBranch() { - // Construct request - const request = { - }; - - // Run request - const response = await retailClient.setDefaultBranch(request); - console.log(response); - } - - callSetDefaultBranch(); - // [END retail_v2beta_generated_CatalogService_SetDefaultBranch_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js deleted file mode 100644 index dee9a094..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.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(attributesConfig) { - // [START retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The - * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. - */ - // const attributesConfig = {} - /** - * Indicates which fields in the provided - * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. - * The following is the only supported field: - * * AttributesConfig.catalog_attributes google.cloud.retail.v2beta.AttributesConfig.catalog_attributes - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateAttributesConfig() { - // Construct request - const request = { - attributesConfig, - }; - - // Run request - const response = await retailClient.updateAttributesConfig(request); - console.log(response); - } - - callUpdateAttributesConfig(); - // [END retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js deleted file mode 100644 index 3f75b996..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_catalog.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(catalog) { - // [START retail_v2beta_generated_CatalogService_UpdateCatalog_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Catalog google.cloud.retail.v2beta.Catalog to update. - * If the caller does not have permission to update the - * Catalog google.cloud.retail.v2beta.Catalog, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * If the Catalog google.cloud.retail.v2beta.Catalog to update does not - * exist, a NOT_FOUND error is returned. - */ - // const catalog = {} - /** - * Indicates which fields in the provided - * Catalog google.cloud.retail.v2beta.Catalog to update. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCatalog() { - // Construct request - const request = { - catalog, - }; - - // Run request - const response = await retailClient.updateCatalog(request); - console.log(response); - } - - callUpdateCatalog(); - // [END retail_v2beta_generated_CatalogService_UpdateCatalog_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js deleted file mode 100644 index d3c451f3..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.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(completionConfig) { - // [START retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The - * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. - * If the caller does not have permission to update the - * CompletionConfig google.cloud.retail.v2beta.CompletionConfig, then a - * PERMISSION_DENIED error is returned. - * If the CompletionConfig google.cloud.retail.v2beta.CompletionConfig to - * update does not exist, a NOT_FOUND error is returned. - */ - // const completionConfig = {} - /** - * Indicates which fields in the provided - * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. - * The following are the only supported fields: - * * CompletionConfig.matching_order google.cloud.retail.v2beta.CompletionConfig.matching_order - * * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions - * * CompletionConfig.min_prefix_length google.cloud.retail.v2beta.CompletionConfig.min_prefix_length - * * CompletionConfig.auto_learning google.cloud.retail.v2beta.CompletionConfig.auto_learning - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callUpdateCompletionConfig() { - // Construct request - const request = { - completionConfig, - }; - - // Run request - const response = await retailClient.updateCompletionConfig(request); - console.log(response); - } - - callUpdateCompletionConfig(); - // [END retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js deleted file mode 100644 index 28957ff1..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.complete_query.js +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(catalog, query) { - // [START retail_v2beta_generated_CompletionService_CompleteQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Catalog for which the completion is performed. - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - */ - // const catalog = 'abc123' - /** - * Required. The query used to generate suggestions. - * The maximum number of allowed characters is 255. - */ - // const query = 'abc123' - /** - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see Tags for - * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - */ - // const languageCodes = 'abc123' - /** - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * Supported formats: - * * `UNKNOWN_DEVICE_TYPE` - * * `DESKTOP` - * * `MOBILE` - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - */ - // const deviceType = 'abc123' - /** - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * CompletionService.ImportCompletionData google.cloud.retail.v2beta.CompletionService.ImportCompletionData. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * Current supported values: - * * user-data - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - */ - // const dataset = 'abc123' - /** - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value - * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions. - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - */ - // const maxSuggestions = 1234 - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callCompleteQuery() { - // Construct request - const request = { - catalog, - query, - }; - - // Run request - const response = await retailClient.completeQuery(request); - console.log(response); - } - - callCompleteQuery(); - // [END retail_v2beta_generated_CompletionService_CompleteQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js b/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js deleted file mode 100644 index 046aa015..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/completion_service.import_completion_data.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, inputConfig) { - // [START retail_v2beta_generated_CompletionService_ImportCompletionData_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog which the suggestions dataset belongs to. - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CompletionServiceClient(); - - async function callImportCompletionData() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importCompletionData(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportCompletionData(); - // [END retail_v2beta_generated_CompletionService_ImportCompletionData_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.js deleted file mode 100644 index 670ed9d8..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.create_control.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, control, controlId) { - // [START retail_v2beta_generated_ControlService_CreateControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of parent catalog. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Required. The Control to create. - */ - // const control = {} - /** - * Required. The ID to use for the Control, which will become the final - * component of the Control's resource name. - * This value should be 4-63 characters, and valid characters - * are /[a-z][0-9]-_/. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callCreateControl() { - // Construct request - const request = { - parent, - control, - controlId, - }; - - // Run request - const response = await retailClient.createControl(request); - console.log(response); - } - - callCreateControl(); - // [END retail_v2beta_generated_ControlService_CreateControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js deleted file mode 100644 index fa617382..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.delete_control.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ControlService_DeleteControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callDeleteControl() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteControl(request); - console.log(response); - } - - callDeleteControl(); - // [END retail_v2beta_generated_ControlService_DeleteControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js deleted file mode 100644 index dcc21c72..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.get_control.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ControlService_GetControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callGetControl() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getControl(request); - console.log(response); - } - - callGetControl(); - // [END retail_v2beta_generated_ControlService_GetControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js deleted file mode 100644 index 5de3859c..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.list_controls.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2beta_generated_ControlService_ListControls_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - /** - * Optional. A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2beta.ListControlsRequest.filter is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - */ - // const filter = 'abc123' - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callListControls() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listControlsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListControls(); - // [END retail_v2beta_generated_ControlService_ListControls_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js deleted file mode 100644 index 3bc73051..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/control_service.update_control.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(control) { - // [START retail_v2beta_generated_ControlService_UpdateControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Control to update. - */ - // const control = {} - /** - * Indicates which fields in the provided - * Control google.cloud.retail.v2beta.Control to update. The following are - * NOT supported: - * * Control.name google.cloud.retail.v2beta.Control.name - * If not set or empty, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ControlServiceClient(); - - async function callUpdateControl() { - // Construct request - const request = { - control, - }; - - // Run request - const response = await retailClient.updateControl(request); - console.log(response); - } - - callUpdateControl(); - // [END retail_v2beta_generated_ControlService_UpdateControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js b/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js deleted file mode 100644 index 38b9394c..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/prediction_service.predict.js +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, userEvent) { - // [START retail_v2beta_generated_PredictionService_Predict_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see Managing - * placements (https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - */ - // const placement = 'abc123' - /** - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - */ - // const userEvent = {} - /** - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - */ - // const pageSize = 1234 - /** - * The previous PredictResponse.next_page_token. - */ - // const pageToken = 'abc123' - /** - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * Examples: - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - */ - // const filter = 'abc123' - /** - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - */ - // const validateOnly = true - /** - * Additional domain specific parameters for the predictions. - * Allowed values: - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - */ - // const params = 1234 - /** - * The labels applied to a resource must meet the following requirements: - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * See Google Cloud - * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - */ - // const labels = 1234 - - // Imports the Retail library - const {PredictionServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new PredictionServiceClient(); - - async function callPredict() { - // Construct request - const request = { - placement, - userEvent, - }; - - // Run request - const response = await retailClient.predict(request); - console.log(response); - } - - callPredict(); - // [END retail_v2beta_generated_PredictionService_Predict_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js deleted file mode 100644 index f25e375d..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type, such - * as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type. - * Duplicate IDs will be automatically ignored. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * If the total number of place IDs exceeds 2000 for this - * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type after - * adding, then the update will be rejected. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * Product google.cloud.retail.v2beta.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddFulfillmentPlaces(); - // [END retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js deleted file mode 100644 index 827fb0fe..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, localInventories) { - // [START retail_v2beta_generated_ProductService_AddLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - */ - // const localInventories = 1234 - /** - * Indicates which inventory fields in the provided list of - * LocalInventory google.cloud.retail.v2beta.LocalInventory to update. The - * field is updated to the provided value. - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const addMask = {} - /** - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - */ - // const addTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, the local inventory will still be processed and retained for at - * most 1 day and processed once the - * Product google.cloud.retail.v2beta.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callAddLocalInventories() { - // Construct request - const request = { - product, - localInventories, - }; - - // Run request - const [operation] = await retailClient.addLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAddLocalInventories(); - // [END retail_v2beta_generated_ProductService_AddLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js deleted file mode 100644 index b6387d2e..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.create_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, product, productId) { - // [START retail_v2beta_generated_ProductService_CreateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - */ - // const parent = 'abc123' - /** - * Required. The Product google.cloud.retail.v2beta.Product to create. - */ - // const product = {} - /** - * Required. The ID to use for the - * Product google.cloud.retail.v2beta.Product, which will become the final - * component of the Product.name google.cloud.retail.v2beta.Product.name. - * If the caller does not have permission to create the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * This field must be unique among all - * Product google.cloud.retail.v2beta.Product s with the same - * parent google.cloud.retail.v2beta.CreateProductRequest.parent. - * Otherwise, an ALREADY_EXISTS error is returned. - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const productId = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - productId, - }; - - // Run request - const response = await retailClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END retail_v2beta_generated_ProductService_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_product.js deleted file mode 100644 index 95f4548f..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.delete_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(name) { - // [START retail_v2beta_generated_ProductService_DeleteProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to delete the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2beta.Product to delete does not - * exist, a NOT_FOUND error is returned. - * The Product google.cloud.retail.v2beta.Product to delete can neither be - * a - * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION - * Product google.cloud.retail.v2beta.Product member nor a - * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY - * Product google.cloud.retail.v2beta.Product with more than one - * variants google.cloud.retail.v2beta.Product.Type.VARIANT. Otherwise, an - * INVALID_ARGUMENT error is returned. - * All inventory information for the named - * Product google.cloud.retail.v2beta.Product will be deleted. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END retail_v2beta_generated_ProductService_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js deleted file mode 100644 index d0520d7e..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.get_product.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ProductService_GetProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * If the requested Product google.cloud.retail.v2beta.Product does not - * exist, a NOT_FOUND error is returned. - */ - // const name = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END retail_v2beta_generated_ProductService_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js deleted file mode 100644 index f7fe86da..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.import_products.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2beta_generated_ProductService_ImportProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. - */ - // const errorsConfig = {} - /** - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - */ - // const updateMask = {} - /** - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * ReconciliationMode.INCREMENTAL google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL. - */ - // const reconciliationMode = {} - /** - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * Only supported when - * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode - * is set to `FULL`. - */ - // const notificationPubsubTopic = 'abc123' - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callImportProducts() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProducts(); - // [END retail_v2beta_generated_ProductService_ImportProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js deleted file mode 100644 index d4971483..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.list_products.js +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2beta_generated_ProductService_ListProducts_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * If the caller does not have permission to list - * Product google.cloud.retail.v2beta.Product s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Product google.cloud.retail.v2beta.Product s to return. - * If unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * If this field is negative, an INVALID_ARGUMENT error is returned. - */ - // const pageSize = 1234 - /** - * A page token - * ListProductsResponse.next_page_token google.cloud.retail.v2beta.ListProductsResponse.next_page_token, - * received from a previous - * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A filter to apply on the list results. Supported features: - * * List all the products under the parent branch if - * filter google.cloud.retail.v2beta.ListProductsRequest.filter is unset. - * * List - * Product.Type.VARIANT google.cloud.retail.v2beta.Product.Type.VARIANT - * Product google.cloud.retail.v2beta.Product s sharing the same - * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY - * Product google.cloud.retail.v2beta.Product. For example: - * `primary_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2beta.Product s bundled in a - * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION - * Product google.cloud.retail.v2beta.Product. - * For example: - * `collection_product_id = "some_product_id"` - * * List Product google.cloud.retail.v2beta.Product s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * If the specified - * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY - * Product google.cloud.retail.v2beta.Product or - * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION - * Product google.cloud.retail.v2beta.Product does not exist, a NOT_FOUND - * error is returned. - */ - // const filter = 'abc123' - /** - * The fields of Product google.cloud.retail.v2beta.Product to return in - * the responses. If not set or empty, the following fields are returned: - * * Product.name google.cloud.retail.v2beta.Product.name - * * Product.id google.cloud.retail.v2beta.Product.id - * * Product.title google.cloud.retail.v2beta.Product.title - * * Product.uri google.cloud.retail.v2beta.Product.uri - * * Product.images google.cloud.retail.v2beta.Product.images - * * Product.price_info google.cloud.retail.v2beta.Product.price_info - * * Product.brands google.cloud.retail.v2beta.Product.brands - * If "*" is provided, all fields are returned. - * Product.name google.cloud.retail.v2beta.Product.name is always returned - * no matter what mask is set. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const readMask = {} - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END retail_v2beta_generated_ProductService_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js deleted file mode 100644 index 3163edcb..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, type, placeIds) { - // [START retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * Supported values: - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . - */ - // const type = 'abc123' - /** - * Required. The IDs for this - * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type, - * such as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type. - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const placeIds = 'abc123' - /** - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * Product google.cloud.retail.v2beta.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveFulfillmentPlaces() { - // Construct request - const request = { - product, - type, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveFulfillmentPlaces(); - // [END retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js deleted file mode 100644 index a61bac1d..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product, placeIds) { - // [START retail_v2beta_generated_ProductService_RemoveLocalInventories_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of - * Product google.cloud.retail.v2beta.Product, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * If the caller does not have permission to access the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - */ - // const product = 'abc123' - /** - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - */ - // const placeIds = 'abc123' - /** - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - */ - // const removeTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * Product google.cloud.retail.v2beta.Product is created. If set to false, - * a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callRemoveLocalInventories() { - // Construct request - const request = { - product, - placeIds, - }; - - // Run request - const [operation] = await retailClient.removeLocalInventories(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRemoveLocalInventories(); - // [END retail_v2beta_generated_ProductService_RemoveLocalInventories_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js deleted file mode 100644 index ac7ceeff..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.set_inventory.js +++ /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 -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(inventory) { - // [START retail_v2beta_generated_ProductService_SetInventory_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The inventory information to update. The allowable fields to - * update are: - * * Product.price_info google.cloud.retail.v2beta.Product.price_info - * * Product.availability google.cloud.retail.v2beta.Product.availability - * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info - * The updated inventory fields must be specified in - * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask. - * If SetInventoryRequest.inventory.name is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2beta.Product named in - * Product.name google.cloud.retail.v2beta.Product.name, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2beta.Product to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * If the Product google.cloud.retail.v2beta.Product to update has existing - * inventory information, the provided inventory information will be merged - * while respecting the last update time for each inventory field, using the - * provided or default value for - * SetInventoryRequest.set_time google.cloud.retail.v2beta.SetInventoryRequest.set_time. - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in SetInventoryRequest.inventory.fulfillment_info - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * * Adds "fulfillment_info" in - * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask - * * Specifies only the desired fulfillment types to clear in - * SetInventoryRequest.inventory.fulfillment_info - * * Checks that only the desired fulfillment info types have empty - * SetInventoryRequest.inventory.fulfillment_info.place_ids - * The last update time is recorded for the following inventory fields: - * * Product.price_info google.cloud.retail.v2beta.Product.price_info - * * Product.availability google.cloud.retail.v2beta.Product.availability - * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity - * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info - * If a full overwrite of inventory information while ignoring timestamps is - * needed, UpdateProduct should be invoked instead. - */ - // const inventory = {} - /** - * Indicates which inventory fields in the provided - * Product google.cloud.retail.v2beta.Product to update. - * At least one field must be provided. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - */ - // const setMask = {} - /** - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - */ - // const setTime = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product with - * name Product.name google.cloud.retail.v2beta.Product.name is not found, - * the inventory update will still be processed and retained for at most 1 day - * until the Product google.cloud.retail.v2beta.Product is created. If set - * to false, a NOT_FOUND error is returned if the - * Product google.cloud.retail.v2beta.Product is not found. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callSetInventory() { - // Construct request - const request = { - inventory, - }; - - // Run request - const [operation] = await retailClient.setInventory(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetInventory(); - // [END retail_v2beta_generated_ProductService_SetInventory_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js b/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js deleted file mode 100644 index ed319228..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/product_service.update_product.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START retail_v2beta_generated_ProductService_UpdateProduct_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The product to update/create. - * If the caller does not have permission to update the - * Product google.cloud.retail.v2beta.Product, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * If the Product google.cloud.retail.v2beta.Product to update does not - * exist and - * allow_missing google.cloud.retail.v2beta.UpdateProductRequest.allow_missing - * is not set, a NOT_FOUND error is returned. - */ - // const product = {} - /** - * Indicates which fields in the provided - * Product google.cloud.retail.v2beta.Product to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - */ - // const updateMask = {} - /** - * If set to true, and the Product google.cloud.retail.v2beta.Product is - * not found, a new Product google.cloud.retail.v2beta.Product will be - * created. In this situation, `update_mask` is ignored. - */ - // const allowMissing = true - - // Imports the Retail library - const {ProductServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ProductServiceClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await retailClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END retail_v2beta_generated_ProductService_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js b/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js deleted file mode 100644 index 62f1df1e..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/search_service.search.js +++ /dev/null @@ -1,261 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(placement, visitorId) { - // [START retail_v2beta_generated_SearchService_Search_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - */ - // const placement = 'abc123' - /** - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - */ - // const branch = 'abc123' - /** - * Raw search query. - */ - // const query = 'abc123' - /** - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * This should be the same identifier as - * UserEvent.visitor_id google.cloud.retail.v2beta.UserEvent.visitor_id. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - */ - // const visitorId = 'abc123' - /** - * User information. - */ - // const userInfo = {} - /** - * Maximum number of Product google.cloud.retail.v2beta.Product s to return. - * If unspecified, defaults to a reasonable value. The maximum allowed value - * is 120. Values above 120 will be coerced to 120. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const pageSize = 1234 - /** - * A page token - * SearchResponse.next_page_token google.cloud.retail.v2beta.SearchResponse.next_page_token, - * received from a previous - * SearchService.Search google.cloud.retail.v2beta.SearchService.Search - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SearchService.Search google.cloud.retail.v2beta.SearchService.Search - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - */ - // const pageToken = 'abc123' - /** - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the Product google.cloud.retail.v2beta.Product s - * deemed by the API as relevant) in search results. This field is only - * considered if - * page_token google.cloud.retail.v2beta.SearchRequest.page_token is unset. - * If this field is negative, an INVALID_ARGUMENT is returned. - */ - // const offset = 1234 - /** - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const filter = 'abc123' - /** - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * SearchRequest.canonical_filter google.cloud.retail.v2beta.SearchRequest.canonical_filter - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * See SearchRequest.filter google.cloud.retail.v2beta.SearchRequest.filter - * for more details about filter syntax. - */ - // const canonicalFilter = 'abc123' - /** - * The order in which products are returned. Products can be ordered by - * a field in an Product google.cloud.retail.v2beta.Product object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this user - * guide (https://cloud.google.com/retail/docs/filter-and-order#order). - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - */ - // const orderBy = 'abc123' - /** - * Facet specifications for faceted search. If empty, no facets are returned. - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - */ - // const facetSpecs = 1234 - /** - * Boost specification to boost certain products. See more details at this - * user guide (https://cloud.google.com/retail/docs/boosting). - * Notice that if both - * ServingConfig.boost_control_ids google.cloud.retail.v2beta.ServingConfig.boost_control_ids - * and SearchRequest.boost_spec are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - */ - // const boostSpec = {} - /** - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this user - * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). - */ - // const queryExpansionSpec = {} - /** - * The keys to fetch and rollup the matching - * variant google.cloud.retail.v2beta.Product.Type.VARIANT - * Product google.cloud.retail.v2beta.Product s attributes, - * FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo or - * LocalInventory google.cloud.retail.v2beta.LocalInventory s attributes. - * The attributes from all the matching - * variant google.cloud.retail.v2beta.Product.Type.VARIANT - * Product google.cloud.retail.v2beta.Product s or - * LocalInventory google.cloud.retail.v2beta.LocalInventory s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * For FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * Supported keys are: - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * Product.inventories.attributes map. - * * attributes.key, where key is any key in the - * Product.attributes google.cloud.retail.v2beta.Product.attributes map. - * * pickupInStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "pickup-in-store". - * * shipToStore.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-1". - * * customFulfillment2.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-2". - * * customFulfillment3.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-3". - * * customFulfillment4.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-4". - * * customFulfillment5.id, where id is any - * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids - * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type - * "custom-type-5". - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - */ - // const variantRollupKeys = 'abc123' - /** - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * UserEvent.page_categories google.cloud.retail.v2beta.UserEvent.page_categories; - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : "Sales > 2017 Black Friday Deals". - */ - // const pageCategories = 'abc123' - /** - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - */ - // const searchMode = {} - /** - * The specification for personalization. - */ - // const personalizationSpec = {} - - // Imports the Retail library - const {SearchServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new SearchServiceClient(); - - async function callSearch() { - // Construct request - const request = { - placement, - visitorId, - }; - - // Run request - const iterable = await retailClient.searchAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearch(); - // [END retail_v2beta_generated_SearchService_Search_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js deleted file mode 100644 index 9086bb91..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.add_control.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig, controlId) { - // [START retail_v2beta_generated_ServingConfigService_AddControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const servingConfig = 'abc123' - /** - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config - if id is not found a NOT_FOUND error is returned. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callAddControl() { - // Construct request - const request = { - servingConfig, - controlId, - }; - - // Run request - const response = await retailClient.addControl(request); - console.log(response); - } - - callAddControl(); - // [END retail_v2beta_generated_ServingConfigService_AddControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js deleted file mode 100644 index fc8ba733..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.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, servingConfig, servingConfigId) { - // [START retail_v2beta_generated_ServingConfigService_CreateServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of parent. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Required. The ServingConfig to create. - */ - // const servingConfig = {} - /** - * Required. The ID to use for the ServingConfig, which will become the final - * component of the ServingConfig's resource name. - * This value should be 4-63 characters, and valid characters - * are /[a-z][0-9]-_/. - */ - // const servingConfigId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callCreateServingConfig() { - // Construct request - const request = { - parent, - servingConfig, - servingConfigId, - }; - - // Run request - const response = await retailClient.createServingConfig(request); - console.log(response); - } - - callCreateServingConfig(); - // [END retail_v2beta_generated_ServingConfigService_CreateServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js deleted file mode 100644 index c9202725..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the ServingConfig to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callDeleteServingConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteServingConfig(request); - console.log(response); - } - - callDeleteServingConfig(); - // [END retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js deleted file mode 100644 index be98fd45..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START retail_v2beta_generated_ServingConfigService_GetServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the ServingConfig to get. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callGetServingConfig() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getServingConfig(request); - console.log(response); - } - - callGetServingConfig(); - // [END retail_v2beta_generated_ServingConfigService_GetServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js deleted file mode 100644 index 7a517f3e..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.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 retail_v2beta_generated_ServingConfigService_ListServingConfigs_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - */ - // const parent = 'abc123' - /** - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callListServingConfigs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listServingConfigsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServingConfigs(); - // [END retail_v2beta_generated_ServingConfigService_ListServingConfigs_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js deleted file mode 100644 index 314b82f9..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig, controlId) { - // [START retail_v2beta_generated_ServingConfigService_RemoveControl_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - */ - // const servingConfig = 'abc123' - /** - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config. - */ - // const controlId = 'abc123' - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callRemoveControl() { - // Construct request - const request = { - servingConfig, - controlId, - }; - - // Run request - const response = await retailClient.removeControl(request); - console.log(response); - } - - callRemoveControl(); - // [END retail_v2beta_generated_ServingConfigService_RemoveControl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js b/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js deleted file mode 100644 index f948464a..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(servingConfig) { - // [START retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ServingConfig to update. - */ - // const servingConfig = {} - /** - * Indicates which fields in the provided - * ServingConfig google.cloud.retail.v2beta.ServingConfig to update. The - * following are NOT supported: - * * ServingConfig.name google.cloud.retail.v2beta.ServingConfig.name - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ServingConfigServiceClient(); - - async function callUpdateServingConfig() { - // Construct request - const request = { - servingConfig, - }; - - // Run request - const response = await retailClient.updateServingConfig(request); - console.log(response); - } - - callUpdateServingConfig(); - // [END retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json b/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json deleted file mode 100644 index 8e89b650..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json +++ /dev/null @@ -1,2131 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-retail", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.retail.v2beta", - "version": "v2beta" - } - ] - }, - "snippets": [ - { - "regionTag": "retail_v2beta_generated_CatalogService_ListCatalogs_async", - "title": "CatalogService listCatalogs Sample", - "origin": "API_DEFINITION", - "description": " Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated with the project.", - "canonical": true, - "file": "catalog_service.list_catalogs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ListCatalogsResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "ListCatalogs", - "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_UpdateCatalog_async", - "title": "CatalogService updateCatalog Sample", - "origin": "API_DEFINITION", - "description": " Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s.", - "canonical": true, - "file": "catalog_service.update_catalog.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": ".google.cloud.retail.v2beta.Catalog" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.Catalog", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCatalog", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_SetDefaultBranch_async", - "title": "CatalogService setDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", - "canonical": true, - "file": "catalog_service.set_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "branch_id", - "type": "TYPE_STRING" - }, - { - "name": "note", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "SetDefaultBranch", - "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_GetDefaultBranch_async", - "title": "CatalogService getDefaultBranch Sample", - "origin": "API_DEFINITION", - "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] method under a specified parent catalog.", - "canonical": true, - "file": "catalog_service.get_default_branch.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.GetDefaultBranchResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "GetDefaultBranch", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_GetCompletionConfig_async", - "title": "CatalogService getCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig].", - "canonical": true, - "file": "catalog_service.get_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async", - "title": "CatalogService updateCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s.", - "canonical": true, - "file": "catalog_service.update_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", - "async": true, - "parameters": [ - { - "name": "completion_config", - "type": ".google.cloud.retail.v2beta.CompletionConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_GetAttributesConfig_async", - "title": "CatalogService getAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig].", - "canonical": true, - "file": "catalog_service.get_attributes_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async", - "title": "CatalogService updateAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", - "canonical": true, - "file": "catalog_service.update_attributes_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": ".google.cloud.retail.v2beta.AttributesConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_AddCatalogAttribute_async", - "title": "CatalogService addCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", - "canonical": true, - "file": "catalog_service.add_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2beta.CatalogAttribute" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async", - "title": "CatalogService removeCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "catalog_service.remove_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "key", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async", - "title": "CatalogService replaceCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "catalog_service.replace_catalog_attribute.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2beta.CatalogAttribute" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2beta.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CompletionService_CompleteQuery_async", - "title": "CatalogService completeQuery Sample", - "origin": "API_DEFINITION", - "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 109, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", - "async": true, - "parameters": [ - { - "name": "catalog", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "language_codes", - "type": "TYPE_STRING[]" - }, - { - "name": "device_type", - "type": "TYPE_STRING" - }, - { - "name": "dataset", - "type": "TYPE_STRING" - }, - { - "name": "max_suggestions", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.retail.v2beta.CompleteQueryResponse", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" - }, - "method": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2beta.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_CompletionService_ImportCompletionData_async", - "title": "CatalogService importCompletionData Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.import_completion_data.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2beta.CompletionDataInputConfig" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" - }, - "method": { - "shortName": "ImportCompletionData", - "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.retail.v2beta.CompletionService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_CreateControl_async", - "title": "CatalogService createControl Sample", - "origin": "API_DEFINITION", - "description": " Creates a Control. If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an ALREADY_EXISTS error is returned.", - "canonical": true, - "file": "control_service.create_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "control", - "type": ".google.cloud.retail.v2beta.Control" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_DeleteControl_async", - "title": "CatalogService deleteControl Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Control. If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.delete_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_UpdateControl_async", - "title": "CatalogService updateControl Sample", - "origin": "API_DEFINITION", - "description": " Updates a Control. [Control][google.cloud.retail.v2beta.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.update_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", - "async": true, - "parameters": [ - { - "name": "control", - "type": ".google.cloud.retail.v2beta.Control" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_GetControl_async", - "title": "CatalogService getControl Sample", - "origin": "API_DEFINITION", - "description": " Gets a Control.", - "canonical": true, - "file": "control_service.get_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ControlService_ListControls_async", - "title": "CatalogService listControls Sample", - "origin": "API_DEFINITION", - "description": " Lists all Controls linked to this catalog.", - "canonical": true, - "file": "control_service.list_controls.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ListControlsResponse", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2beta.ControlServiceClient" - }, - "method": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2beta.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_PredictionService_Predict_async", - "title": "CatalogService predict Sample", - "origin": "API_DEFINITION", - "description": " Makes a recommendation prediction.", - "canonical": true, - "file": "prediction_service.predict.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 153, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2beta.UserEvent" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "params", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.retail.v2beta.PredictResponse", - "client": { - "shortName": "PredictionServiceClient", - "fullName": "google.cloud.retail.v2beta.PredictionServiceClient" - }, - "method": { - "shortName": "Predict", - "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", - "service": { - "shortName": "PredictionService", - "fullName": "google.cloud.retail.v2beta.PredictionService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_CreateProduct_async", - "title": "CatalogService createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Product][google.cloud.retail.v2beta.Product].", - "canonical": true, - "file": "product_service.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.retail.v2beta.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_GetProduct_async", - "title": "CatalogService getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Product][google.cloud.retail.v2beta.Product].", - "canonical": true, - "file": "product_service.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_ListProducts_async", - "title": "CatalogService listProducts Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Product][google.cloud.retail.v2beta.Product]s.", - "canonical": true, - "file": "product_service.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 124, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "read_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.ListProductsResponse", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_UpdateProduct_async", - "title": "CatalogService updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Product][google.cloud.retail.v2beta.Product].", - "canonical": true, - "file": "product_service.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.retail.v2beta.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.retail.v2beta.Product", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_DeleteProduct_async", - "title": "CatalogService deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Product][google.cloud.retail.v2beta.Product].", - "canonical": true, - "file": "product_service.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_ImportProducts_async", - "title": "CatalogService importProducts Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2beta.Product]s to be successfully updated.", - "canonical": true, - "file": "product_service.import_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 85, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2beta.ProductInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "reconciliation_mode", - "type": ".google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode" - }, - { - "name": "notification_pubsub_topic", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "ImportProducts", - "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_SetInventory_async", - "title": "CatalogService setInventory Sample", - "origin": "API_DEFINITION", - "description": " Updates inventory information for a [Product][google.cloud.retail.v2beta.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.set_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 116, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", - "async": true, - "parameters": [ - { - "name": "inventory", - "type": ".google.cloud.retail.v2beta.Product" - }, - { - "name": "set_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "set_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "SetInventory", - "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async", - "title": "CatalogService addFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 107, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "AddFulfillmentPlaces", - "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async", - "title": "CatalogService removeFulfillmentPlaces Sample", - "origin": "API_DEFINITION", - "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 103, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "type", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "RemoveFulfillmentPlaces", - "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_AddLocalInventories_async", - "title": "CatalogService addLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Updates local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be modified using this method. [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.add_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 92, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "local_inventories", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "add_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "add_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "AddLocalInventories", - "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ProductService_RemoveLocalInventories_async", - "title": "CatalogService removeLocalInventories Sample", - "origin": "API_DEFINITION", - "description": " Remove local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be removed using this method. [CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "product_service.remove_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", - "async": true, - "parameters": [ - { - "name": "product", - "type": "TYPE_STRING" - }, - { - "name": "place_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "remove_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductServiceClient", - "fullName": "google.cloud.retail.v2beta.ProductServiceClient" - }, - "method": { - "shortName": "RemoveLocalInventories", - "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", - "service": { - "shortName": "ProductService", - "fullName": "google.cloud.retail.v2beta.ProductService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_SearchService_Search_async", - "title": "CatalogService search Sample", - "origin": "API_DEFINITION", - "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 253, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2beta.SearchService.Search", - "async": true, - "parameters": [ - { - "name": "placement", - "type": "TYPE_STRING" - }, - { - "name": "branch", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "visitor_id", - "type": "TYPE_STRING" - }, - { - "name": "user_info", - "type": ".google.cloud.retail.v2beta.UserInfo" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "offset", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "canonical_filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "facet_specs", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "dynamic_facet_spec", - "type": ".google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec" - }, - { - "name": "boost_spec", - "type": ".google.cloud.retail.v2beta.SearchRequest.BoostSpec" - }, - { - "name": "query_expansion_spec", - "type": ".google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec" - }, - { - "name": "variant_rollup_keys", - "type": "TYPE_STRING[]" - }, - { - "name": "page_categories", - "type": "TYPE_STRING[]" - }, - { - "name": "search_mode", - "type": ".google.cloud.retail.v2beta.SearchRequest.SearchMode" - }, - { - "name": "personalization_spec", - "type": ".google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec" - } - ], - "resultType": ".google.cloud.retail.v2beta.SearchResponse", - "client": { - "shortName": "SearchServiceClient", - "fullName": "google.cloud.retail.v2beta.SearchServiceClient" - }, - "method": { - "shortName": "Search", - "fullName": "google.cloud.retail.v2beta.SearchService.Search", - "service": { - "shortName": "SearchService", - "fullName": "google.cloud.retail.v2beta.SearchService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_CreateServingConfig_async", - "title": "CatalogService createServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise a FAILED_PRECONDITION error is returned.", - "canonical": true, - "file": "serving_config_service.create_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "serving_config", - "type": ".google.cloud.retail.v2beta.ServingConfig" - }, - { - "name": "serving_config_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async", - "title": "CatalogService deleteServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", - "canonical": true, - "file": "serving_config_service.delete_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async", - "title": "CatalogService updateServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates a ServingConfig.", - "canonical": true, - "file": "serving_config_service.update_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": ".google.cloud.retail.v2beta.ServingConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_GetServingConfig_async", - "title": "CatalogService getServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", - "canonical": true, - "file": "serving_config_service.get_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_ListServingConfigs_async", - "title": "CatalogService listServingConfigs Sample", - "origin": "API_DEFINITION", - "description": " Lists all ServingConfigs linked to this catalog.", - "canonical": true, - "file": "serving_config_service.list_serving_configs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ListServingConfigsResponse", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_AddControl_async", - "title": "CatalogService addControl Sample", - "origin": "API_DEFINITION", - "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", - "canonical": true, - "file": "serving_config_service.add_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ServingConfigService_RemoveControl_async", - "title": "CatalogService removeControl Sample", - "origin": "API_DEFINITION", - "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", - "canonical": true, - "file": "serving_config_service.remove_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" - }, - "method": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2beta.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_WriteUserEvent_async", - "title": "CatalogService writeUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event.", - "canonical": true, - "file": "user_event_service.write_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.retail.v2beta.UserEvent" - } - ], - "resultType": ".google.cloud.retail.v2beta.UserEvent", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_CollectUserEvent_async", - "title": "CatalogService collectUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", - "canonical": true, - "file": "user_event_service.collect_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.api.HttpBody", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_PurgeUserEvents_async", - "title": "CatalogService purgeUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", - "canonical": true, - "file": "user_event_service.purge_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 83, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "PurgeUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_ImportUserEvents_async", - "title": "CatalogService importUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", - "canonical": true, - "file": "user_event_service.import_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.retail.v2beta.UserEventInputConfig" - }, - { - "name": "errors_config", - "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_UserEventService_RejoinUserEvents_async", - "title": "CatalogService rejoinUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", - "canonical": true, - "file": "user_event_service.rejoin_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event_rejoin_scope", - "type": ".google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" - }, - "method": { - "shortName": "RejoinUserEvents", - "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.retail.v2beta.UserEventService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js deleted file mode 100644 index 933ec59d..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2beta_generated_UserEventService_CollectUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - */ - // const userEvent = 'abc123' - /** - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - */ - // const uri = 'abc123' - /** - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - */ - // const ets = 1234 - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callCollectUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.collectUserEvent(request); - console.log(response); - } - - callCollectUserEvent(); - // [END retail_v2beta_generated_UserEventService_CollectUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js deleted file mode 100644 index 842e14dd..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, inputConfig) { - // [START retail_v2beta_generated_UserEventService_ImportUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. `projects/1234/locations/global/catalogs/default_catalog` - */ - // const parent = 'abc123' - /** - * Required. The desired input location of the data. - */ - // const inputConfig = {} - /** - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - */ - // const errorsConfig = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callImportUserEvents() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await retailClient.importUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportUserEvents(); - // [END retail_v2beta_generated_UserEventService_ImportUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js deleted file mode 100644 index 059d6944..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, filter) { - // [START retail_v2beta_generated_UserEventService_PurgeUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - */ - // const parent = 'abc123' - /** - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * * `eventType`: Double quoted - * UserEvent.event_type google.cloud.retail.v2beta.UserEvent.event_type - * string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * Examples: - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * The filtering fields are assumed to have an implicit AND. - */ - // const filter = 'abc123' - /** - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - */ - // const force = true - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callPurgeUserEvents() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await retailClient.purgeUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeUserEvents(); - // [END retail_v2beta_generated_UserEventService_PurgeUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js deleted file mode 100644 index aebf64dc..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START retail_v2beta_generated_UserEventService_RejoinUserEvents_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - */ - // const userEventRejoinScope = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callRejoinUserEvents() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await retailClient.rejoinUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callRejoinUserEvents(); - // [END retail_v2beta_generated_UserEventService_RejoinUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js b/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js deleted file mode 100644 index da53a142..00000000 --- a/owl-bot-staging/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, userEvent) { - // [START retail_v2beta_generated_UserEventService_WriteUserEvent_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - - // Imports the Retail library - const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new UserEventServiceClient(); - - async function callWriteUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await retailClient.writeUserEvent(request); - console.log(response); - } - - callWriteUserEvent(); - // [END retail_v2beta_generated_UserEventService_WriteUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2beta/src/index.ts b/owl-bot-staging/v2beta/src/index.ts deleted file mode 100644 index 4f42efab..00000000 --- a/owl-bot-staging/v2beta/src/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 v2beta from './v2beta'; -const CatalogServiceClient = v2beta.CatalogServiceClient; -type CatalogServiceClient = v2beta.CatalogServiceClient; -const CompletionServiceClient = v2beta.CompletionServiceClient; -type CompletionServiceClient = v2beta.CompletionServiceClient; -const ControlServiceClient = v2beta.ControlServiceClient; -type ControlServiceClient = v2beta.ControlServiceClient; -const PredictionServiceClient = v2beta.PredictionServiceClient; -type PredictionServiceClient = v2beta.PredictionServiceClient; -const ProductServiceClient = v2beta.ProductServiceClient; -type ProductServiceClient = v2beta.ProductServiceClient; -const SearchServiceClient = v2beta.SearchServiceClient; -type SearchServiceClient = v2beta.SearchServiceClient; -const ServingConfigServiceClient = v2beta.ServingConfigServiceClient; -type ServingConfigServiceClient = v2beta.ServingConfigServiceClient; -const UserEventServiceClient = v2beta.UserEventServiceClient; -type UserEventServiceClient = v2beta.UserEventServiceClient; -export {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -export default {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts deleted file mode 100644 index 7c74bd3f..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client.ts +++ /dev/null @@ -1,1865 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/catalog_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './catalog_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for managing catalog configuration. - * @class - * @memberof v2beta - */ -export class CatalogServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - catalogServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CatalogServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CatalogServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listCatalogs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'catalogs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.CatalogService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.catalogServiceStub) { - return this.catalogServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.CatalogService. - this.catalogServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.CatalogService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.CatalogService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const catalogServiceStubMethods = - ['listCatalogs', 'updateCatalog', 'setDefaultBranch', 'getDefaultBranch', 'getCompletionConfig', 'updateCompletionConfig', 'getAttributesConfig', 'updateAttributesConfig', 'addCatalogAttribute', 'removeCatalogAttribute', 'replaceCatalogAttribute']; - for (const methodName of catalogServiceStubMethods) { - const callPromise = this.catalogServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.catalogServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Updates the {@link google.cloud.retail.v2beta.Catalog|Catalog}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.Catalog} request.catalog - * Required. The {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2beta.Catalog|Catalog}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.Catalog|Catalog} to update does not - * exist, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Catalog]{@link google.cloud.retail.v2beta.Catalog}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.update_catalog.js - * region_tag:retail_v2beta_generated_CatalogService_UpdateCatalog_async - */ - updateCatalog( - request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|undefined, {}|undefined - ]>; - updateCatalog( - request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): void; - updateCatalog( - request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.ICatalog, - protos.google.cloud.retail.v2beta.IUpdateCatalogRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog.name': request.catalog!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCatalog(request, options, callback); - } -/** - * Set a specified branch id as default branch. API methods such as - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search}, - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct}, - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * will treat requests using "default_branch" to the actual branch id set as - * default. - * - * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as - * default, setting - * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent - * to setting - * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to - * `projects/* /locations/* /catalogs/* /branches/1`. - * - * Using multiple branches can be useful when developers would like - * to have a staging branch to test and verify for future usage. When it - * becomes ready, developers switch on the staging branch using this API while - * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` - * as {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} - * to route the traffic to this staging branch. - * - * CAUTION: If you have live predict/search traffic, switching the default - * branch could potentially cause outages if the ID space of the new branch is - * very different from the old one. - * - * More specifically: - * - * * PredictionService will only return product IDs from branch {newBranch}. - * * SearchService will only return product IDs from branch {newBranch} - * (if branch is not explicitly set). - * * UserEventService will only join events with products from branch - * {newBranch}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Full resource name of the catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.branchId - * The final component of the resource name of a branch. - * - * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT - * error is returned. - * - * If there are no sufficient active products in the targeted branch and - * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.force|force} is not - * set, a FAILED_PRECONDITION error is returned. - * @param {string} request.note - * Some note on this request, this can be retrieved by - * {@link google.cloud.retail.v2beta.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} - * before next valid default branch set occurs. - * - * This field must be a UTF-8 encoded string with a length limit of 1,000 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {boolean} request.force - * If set to true, it permits switching to a branch with - * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id|branch_id} - * even if it has no sufficient active products. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.set_default_branch.js - * region_tag:retail_v2beta_generated_CatalogService_SetDefaultBranch_async - */ - setDefaultBranch( - request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|undefined, {}|undefined - ]>; - setDefaultBranch( - request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - setDefaultBranch( - request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.setDefaultBranch(request, options, callback); - } -/** - * Get which branch is currently default branch set by - * {@link google.cloud.retail.v2beta.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} - * method under a specified parent catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GetDefaultBranchResponse]{@link google.cloud.retail.v2beta.GetDefaultBranchResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.get_default_branch.js - * region_tag:retail_v2beta_generated_CatalogService_GetDefaultBranch_async - */ - getDefaultBranch( - request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|undefined, {}|undefined - ]>; - getDefaultBranch( - request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): void; - getDefaultBranch( - request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, - protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.getDefaultBranch(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full CompletionConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.get_completion_config.js - * region_tag:retail_v2beta_generated_CatalogService_GetCompletionConfig_async - */ - getCompletionConfig( - request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|undefined, {}|undefined - ]>; - getCompletionConfig( - request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getCompletionConfig(request, options, callback); - } -/** - * Updates the - * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.CompletionConfig} request.completionConfig - * Required. The - * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}, then a - * PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to - * update does not exist, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. - * The following are the only supported fields: - * - * * {@link google.cloud.retail.v2beta.CompletionConfig.matching_order|CompletionConfig.matching_order} - * * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} - * * {@link google.cloud.retail.v2beta.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} - * * {@link google.cloud.retail.v2beta.CompletionConfig.auto_learning|CompletionConfig.auto_learning} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.update_completion_config.js - * region_tag:retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async - */ - updateCompletionConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|undefined, {}|undefined - ]>; - updateCompletionConfig( - request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.ICompletionConfig, - protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'completion_config.name': request.completionConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateCompletionConfig(request, options, callback); - } -/** - * Gets an {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.get_attributes_config.js - * region_tag:retail_v2beta_generated_CatalogService_GetAttributesConfig_async - */ - getAttributesConfig( - request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|undefined, {}|undefined - ]>; - getAttributesConfig( - request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getAttributesConfig(request, options, callback); - } -/** - * Updates the - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * The catalog attributes in the request will be updated in the catalog, or - * inserted if they do not exist. Existing catalog attributes not included in - * the request will remain unchanged. Attributes that are assigned to - * products, but do not exist at the catalog level, are always included in the - * response. The product attribute is assigned default values for missing - * catalog attribute fields, e.g., searchable and dynamic facetable options. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.AttributesConfig} request.attributesConfig - * Required. The - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. - * The following is the only supported field: - * - * * {@link google.cloud.retail.v2beta.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.update_attributes_config.js - * region_tag:retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async - */ - updateAttributesConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|undefined, {}|undefined - ]>; - updateAttributesConfig( - request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config.name': request.attributesConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateAttributesConfig(request, options, callback); - } -/** - * Adds the specified - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to the - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to - * add already exists, an ALREADY_EXISTS error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute - * Required. The - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to add. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.add_catalog_attribute.js - * region_tag:retail_v2beta_generated_CatalogService_AddCatalogAttribute_async - */ - addCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|undefined, {}|undefined - ]>; - addCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.addCatalogAttribute(request, options, callback); - } -/** - * Removes the specified - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} from the - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to - * remove does not exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {string} request.key - * Required. The attribute name key of the - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to remove. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.remove_catalog_attribute.js - * region_tag:retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async - */ - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|undefined, {}|undefined - ]>; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.removeCatalogAttribute(request, options, callback); - } -/** - * Replaces the specified - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} in the - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} by updating - * the catalog attribute with the same - * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key}. - * - * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to - * replace does not exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. Full AttributesConfig resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig - * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute - * Required. The updated - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to update. - * The following are NOT supported: - * - * * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.replace_catalog_attribute.js - * region_tag:retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async - */ - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|undefined, {}|undefined - ]>; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IAttributesConfig, - protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig || '', - }); - this.initialize(); - return this.innerApiCalls.replaceCatalogAttribute(request, options, callback); - } - - /** - * Lists all the {@link google.cloud.retail.v2beta.Catalog|Catalog}s associated - * with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. - * If unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Catalog]{@link google.cloud.retail.v2beta.Catalog}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogs( - request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICatalog[], - protos.google.cloud.retail.v2beta.IListCatalogsRequest|null, - protos.google.cloud.retail.v2beta.IListCatalogsResponse - ]>; - listCatalogs( - request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListCatalogsRequest, - protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2beta.ICatalog>): void; - listCatalogs( - request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListCatalogsRequest, - protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2beta.ICatalog>): void; - listCatalogs( - request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.IListCatalogsRequest, - protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2beta.ICatalog>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.IListCatalogsRequest, - protos.google.cloud.retail.v2beta.IListCatalogsResponse|null|undefined, - protos.google.cloud.retail.v2beta.ICatalog>): - Promise<[ - protos.google.cloud.retail.v2beta.ICatalog[], - protos.google.cloud.retail.v2beta.IListCatalogsRequest|null, - protos.google.cloud.retail.v2beta.IListCatalogsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listCatalogs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. - * If unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Catalog]{@link google.cloud.retail.v2beta.Catalog} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCatalogsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCatalogsStream( - request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.createStream( - this.innerApiCalls.listCatalogs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listCatalogs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The account resource name with an associated location. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, - * regardless of whether or not this location exists, a PERMISSION_DENIED - * error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. - * If unspecified, defaults to 50. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Catalog]{@link google.cloud.retail.v2beta.Catalog}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/catalog_service.list_catalogs.js - * region_tag:retail_v2beta_generated_CatalogService_ListCatalogs_async - */ - listCatalogsAsync( - request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCatalogs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCatalogs.asyncIterate( - this.innerApiCalls['listCatalogs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.catalogServiceStub && !this._terminated) { - return this.catalogServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json deleted file mode 100644 index cd2aebd1..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/catalog_service_client_config.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.CatalogService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListCatalogs": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCatalog": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "SetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetDefaultBranch": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetCompletionConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateCompletionConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "GetAttributesConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "UpdateAttributesConfig": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "AddCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "RemoveCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ReplaceCatalogAttribute": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/catalog_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts deleted file mode 100644 index 871a336d..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/completion_service_client.ts +++ /dev/null @@ -1,936 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/completion_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './completion_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Auto-completion service for retail. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2beta - */ -export class CompletionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - completionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CompletionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CompletionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importCompletionDataResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportCompletionDataResponse') as gax.protobuf.Type; - const importCompletionDataMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importCompletionData: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importCompletionDataResponse.decode.bind(importCompletionDataResponse), - importCompletionDataMetadata.decode.bind(importCompletionDataMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.CompletionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.completionServiceStub) { - return this.completionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.CompletionService. - this.completionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.CompletionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.CompletionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const completionServiceStubMethods = - ['completeQuery', 'importCompletionData']; - for (const methodName of completionServiceStubMethods) { - const callPromise = this.completionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.completionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Completes the specified prefix with keyword suggestions. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.catalog - * Required. Catalog for which the completion is performed. - * - * Full resource name of catalog, such as - * `projects/* /locations/global/catalogs/default_catalog`. - * @param {string} request.query - * Required. The query used to generate suggestions. - * - * The maximum number of allowed characters is 255. - * @param {string} request.visitorId - * Required field. A unique identifier for tracking visitors. For example, - * this could be implemented with an HTTP cookie, which should be able to - * uniquely identify a visitor on a single device. This unique identifier - * should not change if the visitor logs in or out of the website. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {string[]} request.languageCodes - * The language filters applied to the output suggestions. If set, it should - * contain the language of the query. If not set, suggestions are returned - * without considering language restrictions. This is the BCP-47 language - * code, such as "en-US" or "sr-Latn". For more information, see [Tags for - * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum - * number of language codes is 3. - * @param {string} request.deviceType - * The device type context for completion suggestions. - * It is useful to apply different suggestions on different device types, e.g. - * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device - * types. - * - * Supported formats: - * - * * `UNKNOWN_DEVICE_TYPE` - * - * * `DESKTOP` - * - * * `MOBILE` - * - * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. - * @param {string} request.dataset - * Determines which dataset to use for fetching completion. "user-data" will - * use the imported dataset through - * {@link google.cloud.retail.v2beta.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. - * "cloud-retail" will use the dataset generated by cloud retail based on user - * events. If leave empty, it will use the "user-data". - * - * Current supported values: - * - * * user-data - * - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. - * @param {number} request.maxSuggestions - * Completion max suggestions. If left unset or set to 0, then will fallback - * to the configured value - * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. - * - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CompleteQueryResponse]{@link google.cloud.retail.v2beta.CompleteQueryResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/completion_service.complete_query.js - * region_tag:retail_v2beta_generated_CompletionService_CompleteQuery_async - */ - completeQuery( - request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|undefined, {}|undefined - ]>; - completeQuery( - request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.ICompleteQueryResponse, - protos.google.cloud.retail.v2beta.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'catalog': request.catalog || '', - }); - this.initialize(); - return this.innerApiCalls.completeQuery(request, options, callback); - } - -/** - * Bulk import of processed completion dataset. - * - * Request processing is asynchronous. Partial updating is not supported. - * - * The operation is successfully finished only after the imported suggestions - * are indexed successfully and ready for serving. The process takes hours. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog which the suggestions dataset belongs to. - * - * Format: `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2beta.CompletionDataInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/completion_service.import_completion_data.js - * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async - */ - importCompletionData( - request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importCompletionData( - request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importCompletionData( - request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importCompletionData(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importCompletionData()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/completion_service.import_completion_data.js - * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async - */ - async checkImportCompletionDataProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importCompletionData, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.completionServiceStub && !this._terminated) { - return this.completionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json deleted file mode 100644 index 1865fe66..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/completion_service_client_config.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.CompletionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CompleteQuery": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "ImportCompletionData": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/completion_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts deleted file mode 100644 index 297b302a..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/control_service_client.ts +++ /dev/null @@ -1,1195 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/control_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './control_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for modifying Control. - * @class - * @memberof v2beta - */ -export class ControlServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - controlServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ControlServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ControlServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listControls: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'controls') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.ControlService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.controlServiceStub) { - return this.controlServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.ControlService. - this.controlServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ControlService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.ControlService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const controlServiceStubMethods = - ['createControl', 'deleteControl', 'updateControl', 'getControl', 'listControls']; - for (const methodName of controlServiceStubMethods) { - const callPromise = this.controlServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.controlServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a Control. - * - * If the {@link google.cloud.retail.v2beta.Control|Control} to create already - * exists, an ALREADY_EXISTS error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full resource name of parent catalog. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {google.cloud.retail.v2beta.Control} request.control - * Required. The Control to create. - * @param {string} request.controlId - * Required. The ID to use for the Control, which will become the final - * component of the Control's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link 0-9|a-z}-_/. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.create_control.js - * region_tag:retail_v2beta_generated_ControlService_CreateControl_async - */ - createControl( - request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|undefined, {}|undefined - ]>; - createControl( - request: protos.google.cloud.retail.v2beta.ICreateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request: protos.google.cloud.retail.v2beta.ICreateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.ICreateControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createControl(request, options, callback); - } -/** - * Deletes a Control. - * - * If the {@link google.cloud.retail.v2beta.Control|Control} to delete does not - * exist, a NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.delete_control.js - * region_tag:retail_v2beta_generated_ControlService_DeleteControl_async - */ - deleteControl( - request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|undefined, {}|undefined - ]>; - deleteControl( - request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteControl(request, options, callback); - } -/** - * Updates a Control. - * - * {@link google.cloud.retail.v2beta.Control|Control} cannot be set to a different - * oneof field, if so an INVALID_ARGUMENT is returned. If the - * {@link google.cloud.retail.v2beta.Control|Control} to delete does not exist, a - * NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.Control} request.control - * Required. The Control to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.Control|Control} to update. The following are - * NOT supported: - * - * * {@link google.cloud.retail.v2beta.Control.name|Control.name} - * - * If not set or empty, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.update_control.js - * region_tag:retail_v2beta_generated_ControlService_UpdateControl_async - */ - updateControl( - request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|undefined, {}|undefined - ]>; - updateControl( - request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IUpdateControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'control.name': request.control!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateControl(request, options, callback); - } -/** - * Gets a Control. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Control to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.get_control.js - * region_tag:retail_v2beta_generated_ControlService_GetControl_async - */ - getControl( - request?: protos.google.cloud.retail.v2beta.IGetControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|undefined, {}|undefined - ]>; - getControl( - request: protos.google.cloud.retail.v2beta.IGetControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request: protos.google.cloud.retail.v2beta.IGetControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request?: protos.google.cloud.retail.v2beta.IGetControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IControl, - protos.google.cloud.retail.v2beta.IGetControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getControl(request, options, callback); - } - - /** - * Lists all Controls linked to this catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Control]{@link google.cloud.retail.v2beta.Control}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listControlsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listControls( - request?: protos.google.cloud.retail.v2beta.IListControlsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IControl[], - protos.google.cloud.retail.v2beta.IListControlsRequest|null, - protos.google.cloud.retail.v2beta.IListControlsResponse - ]>; - listControls( - request: protos.google.cloud.retail.v2beta.IListControlsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListControlsRequest, - protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IControl>): void; - listControls( - request: protos.google.cloud.retail.v2beta.IListControlsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListControlsRequest, - protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IControl>): void; - listControls( - request?: protos.google.cloud.retail.v2beta.IListControlsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.IListControlsRequest, - protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IControl>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.IListControlsRequest, - protos.google.cloud.retail.v2beta.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IControl>): - Promise<[ - protos.google.cloud.retail.v2beta.IControl[], - protos.google.cloud.retail.v2beta.IListControlsRequest|null, - protos.google.cloud.retail.v2beta.IListControlsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listControls(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Control]{@link google.cloud.retail.v2beta.Control} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listControlsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listControlsStream( - request?: protos.google.cloud.retail.v2beta.IListControlsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listControls']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listControls.createStream( - this.innerApiCalls.listControls as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listControls`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 50. Max allowed value is 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListControls` call. - * Provide this to retrieve the subsequent page. - * @param {string} [request.filter] - * Optional. A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. - * * List controls that are used in a single ServingConfig: - * 'serving_config = "boosted_home_page_cvr"' - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Control]{@link google.cloud.retail.v2beta.Control}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/control_service.list_controls.js - * region_tag:retail_v2beta_generated_ControlService_ListControls_async - */ - listControlsAsync( - request?: protos.google.cloud.retail.v2beta.IListControlsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listControls']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listControls.asyncIterate( - this.innerApiCalls['listControls'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.controlServiceStub && !this._terminated) { - return this.controlServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json deleted file mode 100644 index b7572aeb..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/control_service_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.ControlService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListControls": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/control_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json b/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json deleted file mode 100644 index f9c6514c..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/gapic_metadata.json +++ /dev/null @@ -1,571 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.retail.v2beta", - "libraryPackage": "@google-cloud/retail", - "services": { - "CatalogService": { - "clients": { - "grpc": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "GetCompletionConfig": { - "methods": [ - "getCompletionConfig" - ] - }, - "UpdateCompletionConfig": { - "methods": [ - "updateCompletionConfig" - ] - }, - "GetAttributesConfig": { - "methods": [ - "getAttributesConfig" - ] - }, - "UpdateAttributesConfig": { - "methods": [ - "updateAttributesConfig" - ] - }, - "AddCatalogAttribute": { - "methods": [ - "addCatalogAttribute" - ] - }, - "RemoveCatalogAttribute": { - "methods": [ - "removeCatalogAttribute" - ] - }, - "ReplaceCatalogAttribute": { - "methods": [ - "replaceCatalogAttribute" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CatalogServiceClient", - "rpcs": { - "UpdateCatalog": { - "methods": [ - "updateCatalog" - ] - }, - "SetDefaultBranch": { - "methods": [ - "setDefaultBranch" - ] - }, - "GetDefaultBranch": { - "methods": [ - "getDefaultBranch" - ] - }, - "GetCompletionConfig": { - "methods": [ - "getCompletionConfig" - ] - }, - "UpdateCompletionConfig": { - "methods": [ - "updateCompletionConfig" - ] - }, - "GetAttributesConfig": { - "methods": [ - "getAttributesConfig" - ] - }, - "UpdateAttributesConfig": { - "methods": [ - "updateAttributesConfig" - ] - }, - "AddCatalogAttribute": { - "methods": [ - "addCatalogAttribute" - ] - }, - "RemoveCatalogAttribute": { - "methods": [ - "removeCatalogAttribute" - ] - }, - "ReplaceCatalogAttribute": { - "methods": [ - "replaceCatalogAttribute" - ] - }, - "ListCatalogs": { - "methods": [ - "listCatalogs", - "listCatalogsStream", - "listCatalogsAsync" - ] - } - } - } - } - }, - "CompletionService": { - "clients": { - "grpc": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - }, - "ImportCompletionData": { - "methods": [ - "importCompletionData" - ] - } - } - } - } - }, - "ControlService": { - "clients": { - "grpc": { - "libraryClient": "ControlServiceClient", - "rpcs": { - "CreateControl": { - "methods": [ - "createControl" - ] - }, - "DeleteControl": { - "methods": [ - "deleteControl" - ] - }, - "UpdateControl": { - "methods": [ - "updateControl" - ] - }, - "GetControl": { - "methods": [ - "getControl" - ] - }, - "ListControls": { - "methods": [ - "listControls", - "listControlsStream", - "listControlsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ControlServiceClient", - "rpcs": { - "CreateControl": { - "methods": [ - "createControl" - ] - }, - "DeleteControl": { - "methods": [ - "deleteControl" - ] - }, - "UpdateControl": { - "methods": [ - "updateControl" - ] - }, - "GetControl": { - "methods": [ - "getControl" - ] - }, - "ListControls": { - "methods": [ - "listControls", - "listControlsStream", - "listControlsAsync" - ] - } - } - } - } - }, - "PredictionService": { - "clients": { - "grpc": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "PredictionServiceClient", - "rpcs": { - "Predict": { - "methods": [ - "predict" - ] - } - } - } - } - }, - "ProductService": { - "clients": { - "grpc": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductServiceClient", - "rpcs": { - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "ImportProducts": { - "methods": [ - "importProducts" - ] - }, - "SetInventory": { - "methods": [ - "setInventory" - ] - }, - "AddFulfillmentPlaces": { - "methods": [ - "addFulfillmentPlaces" - ] - }, - "RemoveFulfillmentPlaces": { - "methods": [ - "removeFulfillmentPlaces" - ] - }, - "AddLocalInventories": { - "methods": [ - "addLocalInventories" - ] - }, - "RemoveLocalInventories": { - "methods": [ - "removeLocalInventories" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - } - } - } - } - }, - "SearchService": { - "clients": { - "grpc": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - } - } - }, - "ServingConfigService": { - "clients": { - "grpc": { - "libraryClient": "ServingConfigServiceClient", - "rpcs": { - "CreateServingConfig": { - "methods": [ - "createServingConfig" - ] - }, - "DeleteServingConfig": { - "methods": [ - "deleteServingConfig" - ] - }, - "UpdateServingConfig": { - "methods": [ - "updateServingConfig" - ] - }, - "GetServingConfig": { - "methods": [ - "getServingConfig" - ] - }, - "AddControl": { - "methods": [ - "addControl" - ] - }, - "RemoveControl": { - "methods": [ - "removeControl" - ] - }, - "ListServingConfigs": { - "methods": [ - "listServingConfigs", - "listServingConfigsStream", - "listServingConfigsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ServingConfigServiceClient", - "rpcs": { - "CreateServingConfig": { - "methods": [ - "createServingConfig" - ] - }, - "DeleteServingConfig": { - "methods": [ - "deleteServingConfig" - ] - }, - "UpdateServingConfig": { - "methods": [ - "updateServingConfig" - ] - }, - "GetServingConfig": { - "methods": [ - "getServingConfig" - ] - }, - "AddControl": { - "methods": [ - "addControl" - ] - }, - "RemoveControl": { - "methods": [ - "removeControl" - ] - }, - "ListServingConfigs": { - "methods": [ - "listServingConfigs", - "listServingConfigsStream", - "listServingConfigsAsync" - ] - } - } - } - } - }, - "UserEventService": { - "clients": { - "grpc": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "PurgeUserEvents": { - "methods": [ - "purgeUserEvents" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - }, - "RejoinUserEvents": { - "methods": [ - "rejoinUserEvents" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/index.ts b/owl-bot-staging/v2beta/src/v2beta/index.ts deleted file mode 100644 index a7e4f6ba..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {CatalogServiceClient} from './catalog_service_client'; -export {CompletionServiceClient} from './completion_service_client'; -export {ControlServiceClient} from './control_service_client'; -export {PredictionServiceClient} from './prediction_service_client'; -export {ProductServiceClient} from './product_service_client'; -export {SearchServiceClient} from './search_service_client'; -export {ServingConfigServiceClient} from './serving_config_service_client'; -export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts deleted file mode 100644 index 7f5f710e..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client.ts +++ /dev/null @@ -1,837 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/prediction_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './prediction_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for making recommendation prediction. - * @class - * @memberof v2beta - */ -export class PredictionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - predictionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of PredictionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof PredictionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.PredictionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.predictionServiceStub) { - return this.predictionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.PredictionService. - this.predictionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.PredictionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.PredictionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const predictionServiceStubMethods = - ['predict']; - for (const methodName of predictionServiceStubMethods) { - const callPromise = this.predictionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.predictionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Makes a recommendation prediction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. Full resource name of the format: - * {name=projects/* /locations/global/catalogs/default_catalog/placements/*} - * The ID of the Recommendations AI placement. Before you can request - * predictions from your model, you must create at least one placement for it. - * For more information, see [Managing - * placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements). - * - * The full list of available placements can be seen at - * https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements - * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent - * Required. Context about the user, what they are looking at and what action - * they took to trigger the predict request. Note that this user event detail - * won't be ingested to userEvent logs. Thus, a separate userEvent write - * request is required for event logging. - * @param {number} request.pageSize - * Maximum number of results to return per page. Set this property - * to the number of prediction results needed. If zero, the service will - * choose a reasonable default. The maximum allowed value is 100. Values - * above 100 will be coerced to 100. - * @param {string} request.pageToken - * The previous PredictResponse.next_page_token. - * @param {string} request.filter - * Filter for restricting prediction results with a length limit of 5,000 - * characters. Accepts values for tags and the `filterOutOfStockItems` flag. - * - * * Tag expressions. Restricts predictions to products that match all of the - * specified tags. Boolean operators `OR` and `NOT` are supported if the - * expression is enclosed in parentheses, and must be separated from the - * tag values by a space. `-"tagA"` is also supported and is equivalent to - * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings - * with a size limit of 1,000 characters. - * - * Note: "Recently viewed" models don't support tag filtering at the - * moment. - * - * * filterOutOfStockItems. Restricts predictions to products that do not - * have a - * stockState value of OUT_OF_STOCK. - * - * Examples: - * - * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") - * * filterOutOfStockItems tag=(-"promotional") - * * filterOutOfStockItems - * - * If your filter blocks all prediction results, the API will return generic - * (unfiltered) popular products. If you only want results strictly matching - * the filters, set `strictFiltering` to True in `PredictRequest.params` to - * receive empty results instead. - * Note that the API will never return items with storageStatus of "EXPIRED" - * or "DELETED" regardless of filter choices. - * @param {boolean} request.validateOnly - * Use validate only mode for this prediction query. If set to true, a - * dummy model will be used that returns arbitrary products. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - * @param {number[]} request.params - * Additional domain specific parameters for the predictions. - * - * Allowed values: - * - * * `returnProduct`: Boolean. If set to true, the associated product - * object will be returned in the `results.metadata` field in the - * prediction response. - * * `returnScore`: Boolean. If set to true, the prediction 'score' - * corresponding to each returned product will be set in the - * `results.metadata` field in the prediction response. The given - * 'score' indicates the probability of an product being clicked/purchased - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular products instead of empty if - * your filter blocks all prediction results. - * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-price-reranking', 'low-price-reranking', - * 'medium-price-reranking', 'high-price-reranking'}. This gives - * request-level control and adjusts prediction results based on product - * price. - * * `diversityLevel`: String. Default empty. If set to be non-empty, then - * it needs to be one of {'no-diversity', 'low-diversity', - * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives - * request-level control and adjusts prediction results based on product - * category. - * @param {number[]} request.labels - * The labels applied to a resource must meet the following requirements: - * - * * Each resource can have multiple labels, up to a maximum of 64. - * * Each label must be a key-value pair. - * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum - * length of 63 characters. - * * Keys and values can contain only lowercase letters, numeric characters, - * underscores, and dashes. All characters must use UTF-8 encoding, and - * international characters are allowed. - * * The key portion of a label must be unique. However, you can use the same - * key with multiple resources. - * * Keys must start with a lowercase letter or international character. - * - * See [Google Cloud - * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [PredictResponse]{@link google.cloud.retail.v2beta.PredictResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/prediction_service.predict.js - * region_tag:retail_v2beta_generated_PredictionService_Predict_async - */ - predict( - request?: protos.google.cloud.retail.v2beta.IPredictRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|undefined, {}|undefined - ]>; - predict( - request: protos.google.cloud.retail.v2beta.IPredictRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request: protos.google.cloud.retail.v2beta.IPredictRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, - {}|null|undefined>): void; - predict( - request?: protos.google.cloud.retail.v2beta.IPredictRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IPredictResponse, - protos.google.cloud.retail.v2beta.IPredictRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.predict(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.predictionServiceStub && !this._terminated) { - return this.predictionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json deleted file mode 100644 index ab64c45e..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/prediction_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.PredictionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Predict": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/prediction_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts deleted file mode 100644 index 284f15d5..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/product_service_client.ts +++ /dev/null @@ -1,2455 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/product_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting {@link google.cloud.retail.v2beta.Product|Product} - * information of the customer's website. - * @class - * @memberof v2beta - */ -export class ProductServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ProductServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const importProductsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportProductsResponse') as gax.protobuf.Type; - const importProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; - const setInventoryResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.SetInventoryResponse') as gax.protobuf.Type; - const setInventoryMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.SetInventoryMetadata') as gax.protobuf.Type; - const addFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse') as gax.protobuf.Type; - const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata') as gax.protobuf.Type; - const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse') as gax.protobuf.Type; - const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata') as gax.protobuf.Type; - const addLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.AddLocalInventoriesResponse') as gax.protobuf.Type; - const addLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.AddLocalInventoriesMetadata') as gax.protobuf.Type; - const removeLocalInventoriesResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse') as gax.protobuf.Type; - const removeLocalInventoriesMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductsResponse.decode.bind(importProductsResponse), - importProductsMetadata.decode.bind(importProductsMetadata)), - setInventory: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setInventoryResponse.decode.bind(setInventoryResponse), - setInventoryMetadata.decode.bind(setInventoryMetadata)), - addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), - addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata)), - removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeFulfillmentPlacesResponse.decode.bind(removeFulfillmentPlacesResponse), - removeFulfillmentPlacesMetadata.decode.bind(removeFulfillmentPlacesMetadata)), - addLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), - addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata)), - removeLocalInventories: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - removeLocalInventoriesResponse.decode.bind(removeLocalInventoriesResponse), - removeLocalInventoriesMetadata.decode.bind(removeLocalInventoriesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.ProductService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.productServiceStub) { - return this.productServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.ProductService. - this.productServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ProductService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.ProductService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const productServiceStubMethods = - ['createProduct', 'getProduct', 'listProducts', 'updateProduct', 'deleteProduct', 'importProducts', 'setInventory', 'addFulfillmentPlaces', 'removeFulfillmentPlaces', 'addLocalInventories', 'removeLocalInventories']; - for (const methodName of productServiceStubMethods) { - const callPromise = this.productServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.productServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a {@link google.cloud.retail.v2beta.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. - * @param {google.cloud.retail.v2beta.Product} request.product - * Required. The {@link google.cloud.retail.v2beta.Product|Product} to create. - * @param {string} request.productId - * Required. The ID to use for the - * {@link google.cloud.retail.v2beta.Product|Product}, which will become the final - * component of the {@link google.cloud.retail.v2beta.Product.name|Product.name}. - * - * If the caller does not have permission to create the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * This field must be unique among all - * {@link google.cloud.retail.v2beta.Product|Product}s with the same - * {@link google.cloud.retail.v2beta.CreateProductRequest.parent|parent}. - * Otherwise, an ALREADY_EXISTS error is returned. - * - * This field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.create_product.js - * region_tag:retail_v2beta_generated_ProductService_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.retail.v2beta.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.retail.v2beta.ICreateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2beta.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the requested {@link google.cloud.retail.v2beta.Product|Product} does not - * exist, a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.get_product.js - * region_tag:retail_v2beta_generated_ProductService_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.retail.v2beta.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.retail.v2beta.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.retail.v2beta.IGetProductRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.retail.v2beta.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Updates a {@link google.cloud.retail.v2beta.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.Product} request.product - * Required. The product to update/create. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not - * exist and - * {@link google.cloud.retail.v2beta.UpdateProductRequest.allow_missing|allow_missing} - * is not set, a NOT_FOUND error is returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.Product|Product} to update. The immutable and - * output only fields are NOT supported. If not set, all supported fields (the - * fields that are neither immutable nor output only) are updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, a new {@link google.cloud.retail.v2beta.Product|Product} will be - * created. In this situation, `update_mask` is ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.retail.v2beta.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.update_product.js - * region_tag:retail_v2beta_generated_ProductService_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct, - protos.google.cloud.retail.v2beta.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Deletes a {@link google.cloud.retail.v2beta.Product|Product}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to delete the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.Product|Product} to delete does not - * exist, a NOT_FOUND error is returned. - * - * The {@link google.cloud.retail.v2beta.Product|Product} to delete can neither be - * a - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product} member nor a - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product} with more than one - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variants}. Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * All inventory information for the named - * {@link google.cloud.retail.v2beta.Product|Product} will be deleted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.delete_product.js - * region_tag:retail_v2beta_generated_ProductService_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } - -/** - * Bulk import of multiple {@link google.cloud.retail.v2beta.Product|Product}s. - * - * Request processing may be synchronous. No partial updating is supported. - * Non-existing items are created. - * - * Note that it is possible for a subset of the - * {@link google.cloud.retail.v2beta.Product|Product}s to be successfully updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` - * - * If no updateMask is specified, requires products.create permission. - * If updateMask is specified, requires products.update permission. - * @param {string} request.requestId - * Deprecated. This field has no effect. - * @param {google.cloud.retail.v2beta.ProductInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided imported 'products' to update. If - * not set, will by default update all fields. - * @param {google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode} request.reconciliationMode - * The mode of reconciliation between existing products and the products to be - * imported. Defaults to - * {@link google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. - * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, - * when the import is finished, a notification will be sent to - * specified Pub/Sub topic. The message data will be JSON string of a - * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - * - * Only supported when - * {@link google.cloud.retail.v2beta.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} - * is set to `FULL`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.import_products.js - * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async - */ - importProducts( - request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProducts( - request: protos.google.cloud.retail.v2beta.IImportProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request: protos.google.cloud.retail.v2beta.IImportProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProducts( - request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.import_products.js - * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async - */ - async checkImportProductsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importProducts, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates inventory information for a - * {@link google.cloud.retail.v2beta.Product|Product} while respecting the last - * update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, updates are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * When inventory is updated with - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct}, - * the specified inventory field value(s) will overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update time for the specified inventory fields will be overwritten to the - * time of the - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} or - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} - * request. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2beta.CreateProductRequest.product|CreateProductRequest.product}, - * then any pre-existing inventory information for this product will be used. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, - * then any existing inventory information will be preserved. - * - * Pre-existing inventory information can only be updated with - * {@link google.cloud.retail.v2beta.ProductService.SetInventory|SetInventory}, - * {@link google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, - * and - * {@link google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.Product} request.inventory - * Required. The inventory information to update. The allowable fields to - * update are: - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} - * The updated inventory fields must be specified in - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. - * - * If {@link |SetInventoryRequest.inventory.name} is empty or invalid, an - * INVALID_ARGUMENT error is returned. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2beta.Product|Product} named in - * {@link google.cloud.retail.v2beta.Product.name|Product.name}, regardless of - * whether or not it exists, a PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not - * have existing inventory information, the provided inventory information - * will be inserted. - * - * If the {@link google.cloud.retail.v2beta.Product|Product} to update has existing - * inventory information, the provided inventory information will be merged - * while respecting the last update time for each inventory field, using the - * provided or default value for - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. - * - * The caller can replace place IDs for a subset of fulfillment types in the - * following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types and corresponding place IDs - * to update in {@link |SetInventoryRequest.inventory.fulfillment_info} - * - * The caller can clear all place IDs from a subset of fulfillment types in - * the following ways: - * - * * Adds "fulfillment_info" in - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} - * * Specifies only the desired fulfillment types to clear in - * {@link |SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link |SetInventoryRequest.inventory.fulfillment_info.place_ids} - * - * The last update time is recorded for the following inventory fields: - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} - * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} - * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} - * - * If a full overwrite of inventory information while ignoring timestamps is - * needed, {@link |UpdateProduct} should be invoked instead. - * @param {google.protobuf.FieldMask} request.setMask - * Indicates which inventory fields in the provided - * {@link google.cloud.retail.v2beta.Product|Product} to update. - * - * At least one field must be provided. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.setTime - * The time when the request is issued, used to prevent - * out-of-order updates on inventory fields with the last update time - * recorded. If not provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} with - * name {@link google.cloud.retail.v2beta.Product.name|Product.name} is not found, - * the inventory update will still be processed and retained for at most 1 day - * until the {@link google.cloud.retail.v2beta.Product|Product} is created. If set - * to false, a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.set_inventory.js - * region_tag:retail_v2beta_generated_ProductService_SetInventory_async - */ - setInventory( - request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setInventory( - request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setInventory( - request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'inventory.name': request.inventory!.name || '', - }); - this.initialize(); - return this.innerApiCalls.setInventory(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setInventory()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.set_inventory.js - * region_tag:retail_v2beta_generated_ProductService_SetInventory_async - */ - async checkSetInventoryProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.setInventory, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally adds place IDs to - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the added place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}, such - * as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery" to be added for this - * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}. - * Duplicate IDs will be automatically ignored. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * - * If the total number of place IDs exceeds 2000 for this - * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type} after - * adding, then the update will be rejected. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js - * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async - */ - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addFulfillmentPlaces( - request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js - * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async - */ - async checkAddFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Incrementally removes place IDs from a - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the removed place IDs are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * @param {string} request.type - * Required. The fulfillment type, including commonly used types (such as - * pickup in store and same day delivery), and custom types. - * - * Supported values: - * - * * "pickup-in-store" - * * "ship-to-store" - * * "same-day-delivery" - * * "next-day-delivery" - * * "custom-type-1" - * * "custom-type-2" - * * "custom-type-3" - * * "custom-type-4" - * * "custom-type-5" - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. - * @param {string[]} request.placeIds - * Required. The IDs for this - * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}, - * such as the store IDs for "pickup-in-store" or the region IDs for - * "same-day-delivery", to be removed for this - * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}. - * - * At least 1 value is required, and a maximum of 2000 values are allowed. - * Each value must be a string with a length limit of 10 characters, matching - * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the fulfillment updates are issued, used to prevent - * out-of-order updates on fulfillment information. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, the fulfillment information will still be processed and retained - * for at most 1 day and processed once the - * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js - * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async - */ - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeFulfillmentPlaces( - request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeFulfillmentPlaces(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js - * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async - */ - async checkRemoveFulfillmentPlacesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates local inventory information for a - * {@link google.cloud.retail.v2beta.Product|Product} at a list of places, while - * respecting the last update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating - * inventory information. If the request is valid, the update will be enqueued - * and processed downstream. As a consequence, when a response is returned, - * updates are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} - * has no effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * @param {number[]} request.localInventories - * Required. A list of inventory information at difference places. Each place - * is identified by its place ID. At most 3000 inventories are allowed per - * request. - * @param {google.protobuf.FieldMask} request.addMask - * Indicates which inventory fields in the provided list of - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory} to update. The - * field is updated to the provided value. - * - * If a field is set while the place does not have a previous local inventory, - * the local inventory at that store is created. - * - * If a field is set while the value of that field is not provided, the - * original field value, if it exists, is deleted. - * - * If the mask is not set or set with empty paths, all inventory fields will - * be updated. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned and the entire update will be ignored. - * @param {google.protobuf.Timestamp} request.addTime - * The time when the inventory updates are issued. Used to prevent - * out-of-order updates on local inventory fields. If not provided, the - * internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, the local inventory will still be processed and retained for at - * most 1 day and processed once the - * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.add_local_inventories.js - * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async - */ - addLocalInventories( - request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - addLocalInventories( - request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - addLocalInventories( - request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.addLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `addLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.add_local_inventories.js - * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async - */ - async checkAddLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.addLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Remove local inventory information for a - * {@link google.cloud.retail.v2beta.Product|Product} at a list of places at a - * removal timestamp. - * - * This process is asynchronous. If the request is valid, the removal will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, removals are not immediately manifested in the - * {@link google.cloud.retail.v2beta.Product|Product} queried by - * {@link google.cloud.retail.v2beta.ProductService.GetProduct|GetProduct} or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|CreateProduct} - * and - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|UpdateProduct} - * has no effect on local inventories. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.product - * Required. Full resource name of - * {@link google.cloud.retail.v2beta.Product|Product}, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. - * - * If the caller does not have permission to access the - * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not - * it exists, a PERMISSION_DENIED error is returned. - * @param {string[]} request.placeIds - * Required. A list of place IDs to have their inventory deleted. - * At most 3000 place IDs are allowed per request. - * @param {google.protobuf.Timestamp} request.removeTime - * The time when the inventory deletions are issued. Used to prevent - * out-of-order updates and deletions on local inventory fields. If not - * provided, the internal system time will be used. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is - * not found, the local inventory removal request will still be processed and - * retained for at most 1 day and processed once the - * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, - * a NOT_FOUND error is returned if the - * {@link google.cloud.retail.v2beta.Product|Product} is not found. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js - * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async - */ - removeLocalInventories( - request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - removeLocalInventories( - request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - removeLocalInventories( - request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product': request.product || '', - }); - this.initialize(); - return this.innerApiCalls.removeLocalInventories(request, options, callback); - } -/** - * Check the status of the long running operation returned by `removeLocalInventories()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js - * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async - */ - async checkRemoveLocalInventoriesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.removeLocalInventories, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.retail.v2beta.Product|Product}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product} or - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2beta.Product.name|Product.name} - * * {@link google.cloud.retail.v2beta.Product.id|Product.id} - * * {@link google.cloud.retail.v2beta.Product.title|Product.title} - * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2beta.Product.images|Product.images} - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.retail.v2beta.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.retail.v2beta.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct[], - protos.google.cloud.retail.v2beta.IListProductsRequest|null, - protos.google.cloud.retail.v2beta.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.retail.v2beta.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListProductsRequest, - protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IProduct>): void; - listProducts( - request: protos.google.cloud.retail.v2beta.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListProductsRequest, - protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IProduct>): void; - listProducts( - request?: protos.google.cloud.retail.v2beta.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.IListProductsRequest, - protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.IListProductsRequest, - protos.google.cloud.retail.v2beta.IListProductsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IProduct>): - Promise<[ - protos.google.cloud.retail.v2beta.IProduct[], - protos.google.cloud.retail.v2beta.IListProductsRequest|null, - protos.google.cloud.retail.v2beta.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product} or - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2beta.Product.name|Product.name} - * * {@link google.cloud.retail.v2beta.Product.id|Product.id} - * * {@link google.cloud.retail.v2beta.Product.title|Product.title} - * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2beta.Product.images|Product.images} - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.retail.v2beta.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.retail.v2beta.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use - * `default_branch` as the branch ID, to list products under the default - * branch. - * - * If the caller does not have permission to list - * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, - * regardless of whether or not this branch exists, a PERMISSION_DENIED error - * is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to 100. The maximum allowed value is 1000. Values - * above 1000 will be coerced to 1000. - * - * If this field is negative, an INVALID_ARGUMENT error is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {string} request.filter - * A filter to apply on the list results. Supported features: - * - * * List all the products under the parent branch if - * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. - * * List - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} - * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product}. For example: - * `primary_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product}. - * For example: - * `collection_product_id = "some_product_id"` - * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular - * type. For example: - * `type = "PRIMARY"` - * `type = "VARIANT"` - * `type = "COLLECTION"` - * - * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. - * - * If the specified - * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} - * {@link google.cloud.retail.v2beta.Product|Product} or - * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} - * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND - * error is returned. - * @param {google.protobuf.FieldMask} request.readMask - * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in - * the responses. If not set or empty, the following fields are returned: - * - * * {@link google.cloud.retail.v2beta.Product.name|Product.name} - * * {@link google.cloud.retail.v2beta.Product.id|Product.id} - * * {@link google.cloud.retail.v2beta.Product.title|Product.title} - * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} - * * {@link google.cloud.retail.v2beta.Product.images|Product.images} - * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} - * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} - * - * If "*" is provided, all fields are returned. - * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned - * no matter what mask is set. - * - * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error - * is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.retail.v2beta.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/product_service.list_products.js - * region_tag:retail_v2beta_generated_ProductService_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.retail.v2beta.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.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 unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.productServiceStub && !this._terminated) { - return this.productServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json deleted file mode 100644 index 459b579d..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/product_service_client_config.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.ProductService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "GetProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ListProducts": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "UpdateProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "DeleteProduct": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportProducts": { - "timeout_millis": 300000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "SetInventory": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveFulfillmentPlaces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "AddLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "RemoveLocalInventories": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/product_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts deleted file mode 100644 index d3d87c33..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/search_service_client.ts +++ /dev/null @@ -1,1480 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/search_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './search_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * @class - * @memberof v2beta - */ -export class SearchServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - searchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SearchServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SearchServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - branchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - search: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.SearchService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.searchServiceStub) { - return this.searchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.SearchService. - this.searchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.SearchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.SearchService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const searchServiceStubMethods = - ['search']; - for (const methodName of searchServiceStubMethods) { - const callPromise = this.searchServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.searchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Performs a search. - * - * This feature is only available for users who have Retail Search enabled. - * Please enable Retail Search on Cloud Console before using this feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to a reasonable value. The maximum allowed value - * is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if - * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s attributes, - * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - search( - request?: protos.google.cloud.retail.v2beta.ISearchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2beta.ISearchRequest|null, - protos.google.cloud.retail.v2beta.ISearchResponse - ]>; - search( - request: protos.google.cloud.retail.v2beta.ISearchRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.ISearchRequest, - protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): void; - search( - request: protos.google.cloud.retail.v2beta.ISearchRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.ISearchRequest, - protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): void; - search( - request?: protos.google.cloud.retail.v2beta.ISearchRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.ISearchRequest, - protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.ISearchRequest, - protos.google.cloud.retail.v2beta.ISearchResponse|null|undefined, - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult>): - Promise<[ - protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], - protos.google.cloud.retail.v2beta.ISearchRequest|null, - protos.google.cloud.retail.v2beta.ISearchResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - this.initialize(); - return this.innerApiCalls.search(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to a reasonable value. The maximum allowed value - * is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if - * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s attributes, - * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - searchStream( - request?: protos.google.cloud.retail.v2beta.ISearchRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.createStream( - this.innerApiCalls.search as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `search`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.placement - * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` - * This field is used to identify the serving configuration name and the set - * of models that will be used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/catalogs/default_catalog/branches/0`. - * - * Use "default_branch" as the branch ID or leave this field empty, to search - * products under the default branch. - * @param {string} request.query - * Raw search query. - * @param {string} request.visitorId - * Required. A unique identifier for tracking visitors. For example, this - * could be implemented with an HTTP cookie, which should be able to uniquely - * identify a visitor on a single device. This unique identifier should not - * change if the visitor logs in or out of the website. - * - * This should be the same identifier as - * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an INVALID_ARGUMENT error is returned. - * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo - * User information. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. - * If unspecified, defaults to a reasonable value. The maximum allowed value - * is 120. Values above 120 will be coerced to 120. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, - * received from a previous - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * INVALID_ARGUMENT error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s - * deemed by the API as relevant) in search results. This field is only - * considered if - * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. - * - * If this field is negative, an INVALID_ARGUMENT is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the products being filtered. Filter - * expression is case-sensitive. See more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {string} request.canonicalFilter - * The default filter that is applied when a user performs a search without - * checking any filters on the search page. - * - * The filter applied to every search request when quality improvement such as - * query expansion is needed. For example, if a query does not have enough - * results, an expanded query with - * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} - * will be returned as a supplement of the original query. This field is - * strongly recommended to achieve high search quality. - * - * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} - * for more details about filter syntax. - * @param {string} request.orderBy - * The order in which products are returned. Products can be ordered by - * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave - * it unset if ordered by relevance. OrderBy expression is case-sensitive. See - * more details at this [user - * guide](https://cloud.google.com/retail/docs/filter-and-order#order). - * - * If this field is unrecognizable, an INVALID_ARGUMENT is returned. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error - * is returned. - * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec - * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic - * to enable dynamic facets. Do not set this field. - * - * The specification for dynamically generated facets. Notice that only - * textual facets can be dynamically generated. - * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain products. See more details at this - * [user guide](https://cloud.google.com/retail/docs/boosting). - * - * Notice that if both - * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} - * and [SearchRequest.boost_spec] are set, the boost conditions from both - * places are evaluated. If a search request matches multiple boost - * conditions, the final boost score is equal to the sum of the boost scores - * from all matched boost conditions. - * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. See more details at this [user - * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). - * @param {string[]} request.variantRollupKeys - * The keys to fetch and rollup the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s attributes, - * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. - * The attributes from all the matching - * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} - * {@link google.cloud.retail.v2beta.Product|Product}s or - * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and - * de-duplicated. Notice that rollup attributes will lead to extra query - * latency. Maximum number of keys is 30. - * - * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a - * fulfillment type and a fulfillment ID must be provided in the format of - * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", - * "pickupInStore" is fulfillment type and "store123" is the store ID. - * - * Supported keys are: - * - * * colorFamilies - * * price - * * originalPrice - * * discount - * * variantId - * * inventory(place_id,price) - * * inventory(place_id,original_price) - * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. - * * attributes.key, where key is any key in the - * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. - * * pickupInStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "pickup-in-store". - * * shipToStore.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "ship-to-store". - * * sameDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "same-day-delivery". - * * nextDayDelivery.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "next-day-delivery". - * * customFulfillment1.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-1". - * * customFulfillment2.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-2". - * * customFulfillment3.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-3". - * * customFulfillment4.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-4". - * * customFulfillment5.id, where id is any - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} - * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} - * "custom-type-5". - * - * If this field is set to an invalid value other than these, an - * INVALID_ARGUMENT error is returned. - * @param {string[]} request.pageCategories - * The categories associated with a category page. Required for category - * navigation queries to achieve good search quality. The format should be - * the same as - * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; - * - * To represent full path of category, use '>' sign to separate different - * hierarchies. If '>' is part of the category name, please replace it with - * other character(s). - * - * Category pages include special pages such as sales or promotions. For - * instance, a special sale page may have the category hierarchy: - * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. - * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode - * The search mode of the search request. If not specified, a single search - * request triggers both product search and faceted search. - * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec - * The specification for personalization. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/search_service.search.js - * region_tag:retail_v2beta_generated_SearchService_Search_async - */ - searchAsync( - request?: protos.google.cloud.retail.v2beta.ISearchRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'placement': request.placement || '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.asyncIterate( - this.innerApiCalls['search'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified branch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @returns {string} Resource name string. - */ - branchPath(project:string,location:string,catalog:string,branch:string) { - return this.pathTemplates.branchPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - }); - } - - /** - * Parse the project from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).project; - } - - /** - * Parse the location from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).location; - } - - /** - * Parse the catalog from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).catalog; - } - - /** - * Parse the branch from Branch resource. - * - * @param {string} branchName - * A fully-qualified path representing Branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromBranchName(branchName: string) { - return this.pathTemplates.branchPathTemplate.match(branchName).branch; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.searchServiceStub && !this._terminated) { - return this.searchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json deleted file mode 100644 index 82de0f81..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/search_service_client_config.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.SearchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Search": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/search_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts deleted file mode 100644 index 9f807827..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client.ts +++ /dev/null @@ -1,1333 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/serving_config_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './serving_config_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service for modifying ServingConfig. - * @class - * @memberof v2beta - */ -export class ServingConfigServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - servingConfigServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ServingConfigServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ServingConfigServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listServingConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'servingConfigs') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.ServingConfigService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.servingConfigServiceStub) { - return this.servingConfigServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.ServingConfigService. - this.servingConfigServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ServingConfigService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.ServingConfigService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const servingConfigServiceStubMethods = - ['createServingConfig', 'deleteServingConfig', 'updateServingConfig', 'getServingConfig', 'listServingConfigs', 'addControl', 'removeControl']; - for (const methodName of servingConfigServiceStubMethods) { - const callPromise = this.servingConfigServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.servingConfigServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a ServingConfig. - * - * A maximum of 100 {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig}s - * are allowed in a {@link google.cloud.retail.v2beta.Catalog|Catalog}, otherwise - * a FAILED_PRECONDITION error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full resource name of parent. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig - * Required. The ServingConfig to create. - * @param {string} request.servingConfigId - * Required. The ID to use for the ServingConfig, which will become the final - * component of the ServingConfig's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link 0-9|a-z}-_/. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.create_serving_config.js - * region_tag:retail_v2beta_generated_ServingConfigService_CreateServingConfig_async - */ - createServingConfig( - request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|undefined, {}|undefined - ]>; - createServingConfig( - request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.ICreateServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createServingConfig(request, options, callback); - } -/** - * Deletes a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ServingConfig to delete. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.delete_serving_config.js - * region_tag:retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async - */ - deleteServingConfig( - request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|undefined, {}|undefined - ]>; - deleteServingConfig( - request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteServingConfig(request, options, callback); - } -/** - * Updates a ServingConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig - * Required. The ServingConfig to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig} to update. The - * following are NOT supported: - * - * * {@link google.cloud.retail.v2beta.ServingConfig.name|ServingConfig.name} - * - * If not set, all supported fields are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.update_serving_config.js - * region_tag:retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async - */ - updateServingConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|undefined, {}|undefined - ]>; - updateServingConfig( - request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config.name': request.servingConfig!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateServingConfig(request, options, callback); - } -/** - * Gets a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ServingConfig to get. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.get_serving_config.js - * region_tag:retail_v2beta_generated_ServingConfigService_GetServingConfig_async - */ - getServingConfig( - request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|undefined, {}|undefined - ]>; - getServingConfig( - request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IGetServingConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getServingConfig(request, options, callback); - } -/** - * Enables a Control on the specified ServingConfig. - * The control is added in the last position of the list of controls - * it belongs to (e.g. if it's a facet spec control it will be applied - * in the last position of servingConfig.facetSpecIds) - * Returns a ALREADY_EXISTS error if the control has already been applied. - * Returns a FAILED_PRECONDITION error if the addition could exceed maximum - * number of control allowed for that type of control. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {string} request.controlId - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config - if id is not found a NOT_FOUND error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.add_control.js - * region_tag:retail_v2beta_generated_ServingConfigService_AddControl_async - */ - addControl( - request?: protos.google.cloud.retail.v2beta.IAddControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|undefined, {}|undefined - ]>; - addControl( - request: protos.google.cloud.retail.v2beta.IAddControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request: protos.google.cloud.retail.v2beta.IAddControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request?: protos.google.cloud.retail.v2beta.IAddControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IAddControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config': request.servingConfig || '', - }); - this.initialize(); - return this.innerApiCalls.addControl(request, options, callback); - } -/** - * Disables a Control on the specified ServingConfig. - * The control is removed from the ServingConfig. - * Returns a NOT_FOUND error if the Control is not enabled for the - * ServingConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The source ServingConfig resource name . Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} - * @param {string} request.controlId - * Required. The id of the control to apply. Assumed to be in the same catalog - * as the serving config. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.remove_control.js - * region_tag:retail_v2beta_generated_ServingConfigService_RemoveControl_async - */ - removeControl( - request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|undefined, {}|undefined - ]>; - removeControl( - request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig, - protos.google.cloud.retail.v2beta.IRemoveControlRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'serving_config': request.servingConfig || '', - }); - this.initialize(); - return this.innerApiCalls.removeControl(request, options, callback); - } - - /** - * Lists all ServingConfigs linked to this catalog. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listServingConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listServingConfigs( - request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig[], - protos.google.cloud.retail.v2beta.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse - ]>; - listServingConfigs( - request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IServingConfig>): void; - listServingConfigs( - request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IServingConfig>): void; - listServingConfigs( - request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IServingConfig>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IServingConfig>): - Promise<[ - protos.google.cloud.retail.v2beta.IServingConfig[], - protos.google.cloud.retail.v2beta.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2beta.IListServingConfigsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listServingConfigs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listServingConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listServingConfigsStream( - request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listServingConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServingConfigs.createStream( - this.innerApiCalls.listServingConfigs as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServingConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The catalog resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} - * @param {number} [request.pageSize] - * Optional. Maximum number of results to return. If unspecified, defaults - * to 100. If a value greater than 100 is provided, at most 100 results are - * returned. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListServingConfigs` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2beta/serving_config_service.list_serving_configs.js - * region_tag:retail_v2beta_generated_ServingConfigService_ListServingConfigs_async - */ - listServingConfigsAsync( - request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listServingConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServingConfigs.asyncIterate( - this.innerApiCalls['listServingConfigs'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.servingConfigServiceStub && !this._terminated) { - return this.servingConfigServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json deleted file mode 100644 index 2d17b527..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_client_config.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.ServingConfigService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetServingConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListServingConfigs": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AddControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveControl": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/serving_config_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts deleted file mode 100644 index 86906d7b..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client.ts +++ /dev/null @@ -1,1201 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/user_event_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './user_event_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting end user actions on the customer website. - * @class - * @memberof v2beta - */ -export class UserEventServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - userEventServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of UserEventServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof UserEventServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attributesConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' - ), - catalogPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}' - ), - completionConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' - ), - controlPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' - ), - servingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const purgeUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.PurgeUserEventsResponse') as gax.protobuf.Type; - const purgeUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.PurgeMetadata') as gax.protobuf.Type; - const importUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportUserEventsResponse') as gax.protobuf.Type; - const importUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.ImportMetadata') as gax.protobuf.Type; - const rejoinUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RejoinUserEventsResponse') as gax.protobuf.Type; - const rejoinUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.RejoinUserEventsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - purgeUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), - purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata)), - importUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importUserEventsResponse.decode.bind(importUserEventsResponse), - importUserEventsMetadata.decode.bind(importUserEventsMetadata)), - rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), - rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.UserEventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.userEventServiceStub) { - return this.userEventServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.UserEventService. - this.userEventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.UserEventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.UserEventService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const userEventServiceStubMethods = - ['writeUserEvent', 'collectUserEvent', 'purgeUserEvents', 'importUserEvents', 'rejoinUserEvents']; - for (const methodName of userEventServiceStubMethods) { - const callPromise = this.userEventServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.userEventServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'retail.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'retail.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Writes a single user event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent - * Required. User event to write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2beta.UserEvent}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.write_user_event.js - * region_tag:retail_v2beta_generated_UserEventService_WriteUserEvent_async - */ - writeUserEvent( - request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|undefined, {}|undefined - ]>; - writeUserEvent( - request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IUserEvent, - protos.google.cloud.retail.v2beta.IWriteUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.writeUserEvent(request, options, callback); - } -/** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Retail API JavaScript pixel and Google Tag - * Manager. Users should not call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {string} request.userEvent - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - * @param {string} request.uri - * The URL including cgi-parameters but excluding the hash fragment with a - * length limit of 5,000 characters. This is often more useful than the - * referer URL, because many browsers only send the domain for 3rd party - * requests. - * @param {number} request.ets - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [HttpBody]{@link google.api.HttpBody}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.collect_user_event.js - * region_tag:retail_v2beta_generated_UserEventService_CollectUserEvent_async - */ - collectUserEvent( - request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|undefined, {}|undefined - ]>; - collectUserEvent( - request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.retail.v2beta.ICollectUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.collectUserEvent(request, options, callback); - } - -/** - * Deletes permanently all user events specified by the filter provided. - * Depending on the number of events specified by the filter, this operation - * could take hours or days to complete. To test a filter, use the list - * command first. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the catalog under which the events are - * created. The format is - * `projects/${projectId}/locations/global/catalogs/${catalogId}` - * @param {string} request.filter - * Required. The filter string to specify the events to be deleted with a - * length limit of 5,000 characters. Empty string filter is not allowed. The - * eligible fields for filtering are: - * - * * `eventType`: Double quoted - * {@link google.cloud.retail.v2beta.UserEvent.event_type|UserEvent.event_type} - * string. - * * `eventTime`: in ISO 8601 "zulu" format. - * * `visitorId`: Double quoted string. Specifying this will delete all - * events associated with a visitor. - * * `userId`: Double quoted string. Specifying this will delete all events - * associated with a user. - * - * Examples: - * - * * Deleting all events in a time range: - * `eventTime > "2012-04-23T18:25:43.511Z" - * eventTime < "2012-04-23T18:30:43.511Z"` - * * Deleting specific eventType in time range: - * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` - * * Deleting all events for a specific visitor: - * `visitorId = "visitor1024"` - * - * The filtering fields are assumed to have an implicit AND. - * @param {boolean} request.force - * Actually perform the purge. - * If `force` is set to false, the method will return the expected purge count - * without deleting any user events. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async - */ - purgeUserEvents( - request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeUserEvents( - request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeUserEvents( - request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.purgeUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async - */ - async checkPurgeUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.purgeUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. `projects/1234/locations/global/catalogs/default_catalog` - * @param {google.cloud.retail.v2beta.UserEventInputConfig} request.inputConfig - * Required. The desired input location of the data. - * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.import_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async - */ - importUserEvents( - request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importUserEvents( - request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.importUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.import_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async - */ - async checkImportUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a user event rejoin operation with latest product catalog. Events - * will not be annotated with detailed product information if product is - * missing from the catalog at the time the user event is ingested, and these - * events are stored as unjoined events with a limited usage on training and - * serving. This method can be used to start a join operation on specified - * events with latest version of product catalog. It can also be used to - * correct events joined with the wrong product catalog. A rejoin operation - * can take hours or days to complete. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - * @param {google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope - * The type of the user event rejoin to define the scope and range of the user - * events to be rejoined with the latest product catalog. Defaults to - * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an - * invalid integer value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async - */ - rejoinUserEvents( - request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - rejoinUserEvents( - request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - rejoinUserEvents( - request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.rejoinUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `rejoinUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js - * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async - */ - async checkRejoinUserEventsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attributesConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - attributesConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.attributesConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).project; - } - - /** - * Parse the location from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).location; - } - - /** - * Parse the catalog from AttributesConfig resource. - * - * @param {string} attributesConfigName - * A fully-qualified path representing AttributesConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromAttributesConfigName(attributesConfigName: string) { - return this.pathTemplates.attributesConfigPathTemplate.match(attributesConfigName).catalog; - } - - /** - * Return a fully-qualified catalog resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - catalogPath(project:string,location:string,catalog:string) { - return this.pathTemplates.catalogPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).project; - } - - /** - * Parse the location from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).location; - } - - /** - * Parse the catalog from Catalog resource. - * - * @param {string} catalogName - * A fully-qualified path representing Catalog resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCatalogName(catalogName: string) { - return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; - } - - /** - * Return a fully-qualified completionConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @returns {string} Resource name string. - */ - completionConfigPath(project:string,location:string,catalog:string) { - return this.pathTemplates.completionConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - }); - } - - /** - * Parse the project from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).project; - } - - /** - * Parse the location from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).location; - } - - /** - * Parse the catalog from CompletionConfig resource. - * - * @param {string} completionConfigName - * A fully-qualified path representing CompletionConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromCompletionConfigName(completionConfigName: string) { - return this.pathTemplates.completionConfigPathTemplate.match(completionConfigName).catalog; - } - - /** - * Return a fully-qualified control resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} control - * @returns {string} Resource name string. - */ - controlPath(project:string,location:string,catalog:string,control:string) { - return this.pathTemplates.controlPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - control: control, - }); - } - - /** - * Parse the project from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the project. - */ - matchProjectFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).project; - } - - /** - * Parse the location from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the location. - */ - matchLocationFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).location; - } - - /** - * Parse the catalog from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).catalog; - } - - /** - * Parse the control from Control resource. - * - * @param {string} controlName - * A fully-qualified path representing Control resource. - * @returns {string} A string representing the control. - */ - matchControlFromControlName(controlName: string) { - return this.pathTemplates.controlPathTemplate.match(controlName).control; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} branch - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,catalog:string,branch:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - branch: branch, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the catalog from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).catalog; - } - - /** - * Parse the branch from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).branch; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified servingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} serving_config - * @returns {string} Resource name string. - */ - servingConfigPath(project:string,location:string,catalog:string,servingConfig:string) { - return this.pathTemplates.servingConfigPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).project; - } - - /** - * Parse the location from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).location; - } - - /** - * Parse the catalog from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).catalog; - } - - /** - * Parse the serving_config from ServingConfig resource. - * - * @param {string} servingConfigName - * A fully-qualified path representing ServingConfig resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromServingConfigName(servingConfigName: string) { - return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.userEventServiceStub && !this._terminated) { - return this.userEventServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json b/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json deleted file mode 100644 index f5bd2bae..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/user_event_service_client_config.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.UserEventService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "49abb7cadc111ff8dd551b61fcad123362c8d090": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 300000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "WriteUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "CollectUserEvent": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - }, - "PurgeUserEvents": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" - }, - "ImportUserEvents": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" - }, - "RejoinUserEvents": { - "timeout_millis": 5000, - "retry_codes_name": "idempotent", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json b/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json deleted file mode 100644 index 7cee73e6..00000000 --- a/owl-bot-staging/v2beta/src/v2beta/user_event_service_proto_list.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - "../../protos/google/cloud/retail/v2beta/catalog.proto", - "../../protos/google/cloud/retail/v2beta/catalog_service.proto", - "../../protos/google/cloud/retail/v2beta/common.proto", - "../../protos/google/cloud/retail/v2beta/completion_service.proto", - "../../protos/google/cloud/retail/v2beta/control.proto", - "../../protos/google/cloud/retail/v2beta/control_service.proto", - "../../protos/google/cloud/retail/v2beta/export_config.proto", - "../../protos/google/cloud/retail/v2beta/import_config.proto", - "../../protos/google/cloud/retail/v2beta/prediction_service.proto", - "../../protos/google/cloud/retail/v2beta/product.proto", - "../../protos/google/cloud/retail/v2beta/product_service.proto", - "../../protos/google/cloud/retail/v2beta/promotion.proto", - "../../protos/google/cloud/retail/v2beta/purge_config.proto", - "../../protos/google/cloud/retail/v2beta/search_service.proto", - "../../protos/google/cloud/retail/v2beta/serving_config.proto", - "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", - "../../protos/google/cloud/retail/v2beta/user_event.proto", - "../../protos/google/cloud/retail/v2beta/user_event_service.proto" -] diff --git a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 57b7c7be..00000000 --- a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const retail = require('@google-cloud/retail'); - -function main() { - const catalogServiceClient = new retail.CatalogServiceClient(); - const completionServiceClient = new retail.CompletionServiceClient(); - const controlServiceClient = new retail.ControlServiceClient(); - const predictionServiceClient = new retail.PredictionServiceClient(); - const productServiceClient = new retail.ProductServiceClient(); - const searchServiceClient = new retail.SearchServiceClient(); - const servingConfigServiceClient = new retail.ServingConfigServiceClient(); - const userEventServiceClient = new retail.UserEventServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 25eaae42..00000000 --- a/owl-bot-staging/v2beta/system-test/fixtures/sample/src/index.ts +++ /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. ** - -import {CatalogServiceClient, CompletionServiceClient, ControlServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient} from '@google-cloud/retail'; - -// check that the client class type name can be used -function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { - client.close(); -} -function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { - client.close(); -} -function doStuffWithControlServiceClient(client: ControlServiceClient) { - client.close(); -} -function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { - client.close(); -} -function doStuffWithProductServiceClient(client: ProductServiceClient) { - client.close(); -} -function doStuffWithSearchServiceClient(client: SearchServiceClient) { - client.close(); -} -function doStuffWithServingConfigServiceClient(client: ServingConfigServiceClient) { - client.close(); -} -function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const catalogServiceClient = new CatalogServiceClient(); - doStuffWithCatalogServiceClient(catalogServiceClient); - // check that the client instance can be created - const completionServiceClient = new CompletionServiceClient(); - doStuffWithCompletionServiceClient(completionServiceClient); - // check that the client instance can be created - const controlServiceClient = new ControlServiceClient(); - doStuffWithControlServiceClient(controlServiceClient); - // check that the client instance can be created - const predictionServiceClient = new PredictionServiceClient(); - doStuffWithPredictionServiceClient(predictionServiceClient); - // check that the client instance can be created - const productServiceClient = new ProductServiceClient(); - doStuffWithProductServiceClient(productServiceClient); - // check that the client instance can be created - const searchServiceClient = new SearchServiceClient(); - doStuffWithSearchServiceClient(searchServiceClient); - // check that the client instance can be created - const servingConfigServiceClient = new ServingConfigServiceClient(); - doStuffWithServingConfigServiceClient(servingConfigServiceClient); - // check that the client instance can be created - const userEventServiceClient = new UserEventServiceClient(); - doStuffWithUserEventServiceClient(userEventServiceClient); -} - -main(); diff --git a/owl-bot-staging/v2beta/system-test/install.ts b/owl-bot-staging/v2beta/system-test/install.ts deleted file mode 100644 index 8ec45222..00000000 --- a/owl-bot-staging/v2beta/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/v2beta/test/gapic_catalog_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts deleted file mode 100644 index c264bc2d..00000000 --- a/owl-bot-staging/v2beta/test/gapic_catalog_service_v2beta.ts +++ /dev/null @@ -1,1790 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as catalogserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.CatalogServiceClient', () => { - it('has servicePath', () => { - const servicePath = catalogserviceModule.v2beta.CatalogServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = catalogserviceModule.v2beta.CatalogServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = catalogserviceModule.v2beta.CatalogServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - await client.initialize(); - assert(client.catalogServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.catalogServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.catalogServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('updateCatalog', () => { - it('invokes updateCatalog without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); - const [response] = await client.updateCatalog(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()); - client.innerApiCalls.updateCatalog = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCatalog( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICatalog|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCatalog with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedHeaderRequestParams = "catalog.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCatalog(request), expectedError); - assert((client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCatalog with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCatalogRequest()); - request.catalog = {}; - request.catalog.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCatalog(request), expectedError); - }); - }); - - describe('setDefaultBranch', () => { - it('invokes setDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.setDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.setDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setDefaultBranch( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setDefaultBranch(request), expectedError); - assert((client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setDefaultBranch(request), expectedError); - }); - }); - - describe('getDefaultBranch', () => { - it('invokes getDefaultBranch without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.getDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse()); - client.innerApiCalls.getDefaultBranch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDefaultBranch( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDefaultBranch with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDefaultBranch(request), expectedError); - assert((client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDefaultBranch with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDefaultBranch(request), expectedError); - }); - }); - - describe('getCompletionConfig', () => { - it('invokes getCompletionConfig without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCompletionConfig without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); - client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getCompletionConfig with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCompletionConfig(request), expectedError); - assert((client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCompletionConfig with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getCompletionConfig(request), expectedError); - }); - }); - - describe('updateCompletionConfig', () => { - it('invokes updateCompletionConfig without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCompletionConfig without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompletionConfig()); - client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCompletionConfig with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedHeaderRequestParams = "completion_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - assert((client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCompletionConfig with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest()); - request.completionConfig = {}; - request.completionConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - }); - }); - - describe('getAttributesConfig', () => { - it('invokes getAttributesConfig without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAttributesConfig without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getAttributesConfig with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttributesConfig(request), expectedError); - assert((client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAttributesConfig with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAttributesConfig(request), expectedError); - }); - }); - - describe('updateAttributesConfig', () => { - it('invokes updateAttributesConfig without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAttributesConfig without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateAttributesConfig with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedHeaderRequestParams = "attributes_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - assert((client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAttributesConfig with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest()); - request.attributesConfig = {}; - request.attributesConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - }); - }); - - describe('addCatalogAttribute', () => { - it('invokes addCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.addCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - }); - }); - - describe('removeCatalogAttribute', () => { - it('invokes removeCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.removeCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - }); - }); - - describe('replaceCatalogAttribute', () => { - it('invokes replaceCatalogAttribute without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.replaceCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes replaceCatalogAttribute without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.AttributesConfig()); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.replaceCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes replaceCatalogAttribute with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedHeaderRequestParams = "attributes_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - assert((client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes replaceCatalogAttribute with closed client', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest()); - request.attributesConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - }); - }); - - describe('listCatalogs', () => { - it('invokes listCatalogs without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); - const [response] = await client.listCatalogs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogs without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - ]; - client.innerApiCalls.listCatalogs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCatalogs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICatalog[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listCatalogs with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCatalogs(request), expectedError); - assert((client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCatalogsStream without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - ]; - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listCatalogsStream with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCatalogsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Catalog) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCatalogs, request)); - assert.strictEqual( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), - ]; - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; - const iterable = client.listCatalogsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCatalogs with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListCatalogsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listCatalogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCatalogsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts deleted file mode 100644 index 26af45db..00000000 --- a/owl-bot-staging/v2beta/test/gapic_completion_service_v2beta.ts +++ /dev/null @@ -1,703 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as completionserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2beta.CompletionServiceClient', () => { - it('has servicePath', () => { - const servicePath = completionserviceModule.v2beta.CompletionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = completionserviceModule.v2beta.CompletionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = completionserviceModule.v2beta.CompletionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - await client.initialize(); - assert(client.completionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.completionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery without error using callback', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryResponse()); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes completeQuery with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); - request.catalog = ''; - const expectedHeaderRequestParams = "catalog="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - assert((client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes completeQuery with closed client', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CompleteQueryRequest()); - request.catalog = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.completeQuery(request), expectedError); - }); - }); - - describe('importCompletionData', () => { - it('invokes importCompletionData without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCall(expectedResponse); - const [operation] = await client.importCompletionData(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData without error using callback', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importCompletionData = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importCompletionData( - request, - (err?: Error|null, - result?: LROperation|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.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importCompletionData with call error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importCompletionData(request), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importCompletionData with LRO error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importCompletionData(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportCompletionDataProgress without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportCompletionDataProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportCompletionDataProgress with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportCompletionDataProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts deleted file mode 100644 index 4ba4bd3c..00000000 --- a/owl-bot-staging/v2beta/test/gapic_control_service_v2beta.ts +++ /dev/null @@ -1,1108 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as controlserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.ControlServiceClient', () => { - it('has servicePath', () => { - const servicePath = controlserviceModule.v2beta.ControlServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = controlserviceModule.v2beta.ControlServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = controlserviceModule.v2beta.ControlServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new controlserviceModule.v2beta.ControlServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.controlServiceStub, undefined); - await client.initialize(); - assert(client.controlServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.controlServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.controlServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createControl', () => { - it('invokes createControl without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); - const [response] = await client.createControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createControl without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createControl with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createControl(request), expectedError); - assert((client.innerApiCalls.createControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createControl with closed client', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateControlRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createControl(request), expectedError); - }); - }); - - describe('deleteControl', () => { - it('invokes deleteControl without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); - const [response] = await client.deleteControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteControl without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteControl( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteControl with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteControl(request), expectedError); - assert((client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteControl with closed client', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteControlRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteControl(request), expectedError); - }); - }); - - describe('updateControl', () => { - it('invokes updateControl without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); - const [response] = await client.updateControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateControl without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateControl with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedHeaderRequestParams = "control.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateControl(request), expectedError); - assert((client.innerApiCalls.updateControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateControl with closed client', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateControlRequest()); - request.control = {}; - request.control.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateControl(request), expectedError); - }); - }); - - describe('getControl', () => { - it('invokes getControl without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); - const [response] = await client.getControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getControl without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()); - client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getControl with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getControl(request), expectedError); - assert((client.innerApiCalls.getControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getControl with closed client', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetControlRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getControl(request), expectedError); - }); - }); - - describe('listControls', () => { - it('invokes listControls without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); - const [response] = await client.listControls(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listControls without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listControls( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IControl[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listControls with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listControls(request), expectedError); - assert((client.innerApiCalls.listControls as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listControlsStream without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - ]; - client.descriptors.page.listControls.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listControlsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Control) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listControls, request)); - assert.strictEqual( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listControlsStream with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listControls.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listControlsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Control) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listControls, request)); - assert.strictEqual( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listControls without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), - ]; - client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.IControl[] = []; - const iterable = client.listControlsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listControls with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListControlsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listControlsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2beta.IControl[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts deleted file mode 100644 index ca636e40..00000000 --- a/owl-bot-staging/v2beta/test/gapic_prediction_service_v2beta.ts +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as predictionserviceModule from '../src'; - -import {protobuf} 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('v2beta.PredictionServiceClient', () => { - it('has servicePath', () => { - const servicePath = predictionserviceModule.v2beta.PredictionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = predictionserviceModule.v2beta.PredictionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = predictionserviceModule.v2beta.PredictionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - await client.initialize(); - assert(client.predictionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.predictionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.predictionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('predict', () => { - it('invokes predict without error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCall(expectedResponse); - const [response] = await client.predict(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict without error using callback', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictResponse()); - client.innerApiCalls.predict = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.predict( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IPredictResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes predict with error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.predict(request), expectedError); - assert((client.innerApiCalls.predict as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes predict with closed client', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PredictRequest()); - request.placement = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.predict(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts deleted file mode 100644 index b483f593..00000000 --- a/owl-bot-staging/v2beta/test/gapic_product_service_v2beta.ts +++ /dev/null @@ -1,2046 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as productserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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('v2beta.ProductServiceClient', () => { - it('has servicePath', () => { - const servicePath = productserviceModule.v2beta.ProductServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productserviceModule.v2beta.ProductServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productserviceModule.v2beta.ProductServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productserviceModule.v2beta.ProductServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - await client.initialize(); - assert(client.productServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateProductRequest()); - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetProductRequest()); - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateProductRequest()); - request.product = {}; - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('importProducts', () => { - it('invokes importProducts without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProducts( - request, - (err?: Error|null, - result?: LROperation|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.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProducts with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProducts(request), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProducts with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductsProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductsProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setInventory', () => { - it('invokes setInventory without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); - const [operation] = await client.setInventory(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.setInventory = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setInventory( - request, - (err?: Error|null, - result?: LROperation|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.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setInventory with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInventory(request), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setInventory with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SetInventoryRequest()); - request.inventory = {}; - request.inventory.name = ''; - const expectedHeaderRequestParams = "inventory.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInventory(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.setInventory as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkSetInventoryProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSetInventoryProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetInventoryProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSetInventoryProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addFulfillmentPlaces', () => { - it('invokes addFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.addFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeFulfillmentPlaces', () => { - it('invokes removeFulfillmentPlaces without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeFulfillmentPlaces(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeFulfillmentPlaces( - request, - (err?: Error|null, - result?: LROperation|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.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeFulfillmentPlaces with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeFulfillmentPlaces with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveFulfillmentPlacesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveFulfillmentPlacesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('addLocalInventories', () => { - it('invokes addLocalInventories without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.addLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.addLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addLocalInventories with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addLocalInventories(request), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAddLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAddLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('removeLocalInventories', () => { - it('invokes removeLocalInventories without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(expectedResponse); - const [operation] = await client.removeLocalInventories(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.removeLocalInventories = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeLocalInventories( - request, - (err?: Error|null, - result?: LROperation|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.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeLocalInventories with call error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeLocalInventories(request), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeLocalInventories with LRO error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest()); - request.product = ''; - const expectedHeaderRequestParams = "product="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRemoveLocalInventoriesProgress without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemoveLocalInventoriesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRemoveLocalInventoriesProgress with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemoveLocalInventoriesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - 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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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.retail.v2beta.Product[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.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 productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.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.retail.v2beta.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts deleted file mode 100644 index f654dd43..00000000 --- a/owl-bot-staging/v2beta/test/gapic_search_service_v2beta.ts +++ /dev/null @@ -1,770 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as searchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.SearchServiceClient', () => { - it('has servicePath', () => { - const servicePath = searchserviceModule.v2beta.SearchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = searchserviceModule.v2beta.SearchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = searchserviceModule.v2beta.SearchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new searchserviceModule.v2beta.SearchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - await client.initialize(); - assert(client.searchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.searchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('search', () => { - it('invokes search without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCall(expectedResponse); - const [response] = await client.search(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes search without error using callback', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.search( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes search with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - assert((client.innerApiCalls.search as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchStream without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes searchStream with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedError = new Error('expected'); - client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert.strictEqual( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = []; - const iterable = client.searchAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with search with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.SearchRequest()); - request.placement = ''; - const expectedHeaderRequestParams = "placement=";const expectedError = new Error('expected'); - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('branch', () => { - const fakePath = "/rendered/path/branch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.branchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.branchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('branchPath', () => { - const result = client.branchPath("projectValue", "locationValue", "catalogValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.branchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBranchName', () => { - const result = client.matchProjectFromBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromBranchName', () => { - const result = client.matchLocationFromBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromBranchName', () => { - const result = client.matchCatalogFromBranchName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromBranchName', () => { - const result = client.matchBranchFromBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.branchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts deleted file mode 100644 index f7adf822..00000000 --- a/owl-bot-staging/v2beta/test/gapic_serving_config_service_v2beta.ts +++ /dev/null @@ -1,1302 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as servingconfigserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.ServingConfigServiceClient', () => { - it('has servicePath', () => { - const servicePath = servingconfigserviceModule.v2beta.ServingConfigServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = servingconfigserviceModule.v2beta.ServingConfigServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = servingconfigserviceModule.v2beta.ServingConfigServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servingConfigServiceStub, undefined); - await client.initialize(); - assert(client.servingConfigServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.servingConfigServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servingConfigServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createServingConfig', () => { - it('invokes createServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.createServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createServingConfig(request), expectedError); - assert((client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CreateServingConfigRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createServingConfig(request), expectedError); - }); - }); - - describe('deleteServingConfig', () => { - it('invokes deleteServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.deleteServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteServingConfig( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteServingConfig(request), expectedError); - assert((client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteServingConfig(request), expectedError); - }); - }); - - describe('updateServingConfig', () => { - it('invokes updateServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedHeaderRequestParams = "serving_config.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateServingConfig(request), expectedError); - assert((client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest()); - request.servingConfig = {}; - request.servingConfig.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateServingConfig(request), expectedError); - }); - }); - - describe('getServingConfig', () => { - it('invokes getServingConfig without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServingConfig(request), expectedError); - assert((client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.GetServingConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getServingConfig(request), expectedError); - }); - }); - - describe('addControl', () => { - it('invokes addControl without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); - const [response] = await client.addControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addControl with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addControl(request), expectedError); - assert((client.innerApiCalls.addControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addControl with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.AddControlRequest()); - request.servingConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addControl(request), expectedError); - }); - }); - - describe('removeControl', () => { - it('invokes removeControl without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); - const [response] = await client.removeControl(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()); - client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeControl with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); - request.servingConfig = ''; - const expectedHeaderRequestParams = "serving_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeControl(request), expectedError); - assert((client.innerApiCalls.removeControl as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeControl with closed client', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RemoveControlRequest()); - request.servingConfig = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeControl(request), expectedError); - }); - }); - - describe('listServingConfigs', () => { - it('invokes listServingConfigs without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listServingConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServingConfigs without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServingConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IServingConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServingConfigs(request), expectedError); - assert((client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServingConfigsStream without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - ]; - client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServingConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.ServingConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listServingConfigsStream with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listServingConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServingConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.ServingConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServingConfigs, request)); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServingConfigs without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.ServingConfig()), - ]; - client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = []; - const iterable = client.listServingConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ListServingConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServingConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts b/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts deleted file mode 100644 index dd385461..00000000 --- a/owl-bot-staging/v2beta/test/gapic_user_event_service_v2beta.ts +++ /dev/null @@ -1,1088 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as usereventserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} 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('v2beta.UserEventServiceClient', () => { - it('has servicePath', () => { - const servicePath = usereventserviceModule.v2beta.UserEventServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = usereventserviceModule.v2beta.UserEventServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = usereventserviceModule.v2beta.UserEventServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - await client.initialize(); - assert(client.userEventServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.userEventServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('writeUserEvent', () => { - it('invokes writeUserEvent without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.writeUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.retail.v2beta.UserEvent()); - client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.writeUserEvent( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IUserEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes writeUserEvent with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - assert((client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes writeUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.WriteUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.writeUserEvent(request), expectedError); - }); - }); - - describe('collectUserEvent', () => { - it('invokes collectUserEvent without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.api.HttpBody()); - client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.collectUserEvent( - request, - (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes collectUserEvent with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - assert((client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes collectUserEvent with closed client', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.CollectUserEventRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.collectUserEvent(request), expectedError); - }); - }); - - describe('purgeUserEvents', () => { - it('invokes purgeUserEvents without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeUserEvents with call error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeUserEvents(request), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importUserEvents', () => { - it('invokes importUserEvents without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.importUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importUserEvents with call error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.ImportUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('rejoinUserEvents', () => { - it('invokes rejoinUserEvents without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.rejoinUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rejoinUserEvents( - request, - (err?: Error|null, - result?: LROperation|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.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes rejoinUserEvents with call error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejoinUserEvents(request), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rejoinUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejoinUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkRejoinUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRejoinUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRejoinUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRejoinUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attributesConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attributesConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attributesConfigPath', () => { - const result = client.attributesConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attributesConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttributesConfigName', () => { - const result = client.matchProjectFromAttributesConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttributesConfigName', () => { - const result = client.matchLocationFromAttributesConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromAttributesConfigName', () => { - const result = client.matchCatalogFromAttributesConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('catalog', () => { - const fakePath = "/rendered/path/catalog"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.catalogPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.catalogPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('catalogPath', () => { - const result = client.catalogPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.catalogPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCatalogName', () => { - const result = client.matchProjectFromCatalogName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCatalogName', () => { - const result = client.matchLocationFromCatalogName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCatalogName', () => { - const result = client.matchCatalogFromCatalogName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.catalogPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.completionConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.completionConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('completionConfigPath', () => { - const result = client.completionConfigPath("projectValue", "locationValue", "catalogValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.completionConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompletionConfigName', () => { - const result = client.matchProjectFromCompletionConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCompletionConfigName', () => { - const result = client.matchLocationFromCompletionConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromCompletionConfigName', () => { - const result = client.matchCatalogFromCompletionConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.completionConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('control', () => { - const fakePath = "/rendered/path/control"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - control: "controlValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.controlPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.controlPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('controlPath', () => { - const result = client.controlPath("projectValue", "locationValue", "catalogValue", "controlValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.controlPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromControlName', () => { - const result = client.matchProjectFromControlName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromControlName', () => { - const result = client.matchLocationFromControlName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromControlName', () => { - const result = client.matchCatalogFromControlName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchControlFromControlName', () => { - const result = client.matchControlFromControlName(fakePath); - assert.strictEqual(result, "controlValue"); - assert((client.pathTemplates.controlPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - branch: "branchValue", - product: "productValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "catalogValue", "branchValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromProductName', () => { - const result = client.matchCatalogFromProductName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProductName', () => { - const result = client.matchBranchFromProductName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servingConfigPath', () => { - const result = client.servingConfigPath("projectValue", "locationValue", "catalogValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServingConfigName', () => { - const result = client.matchProjectFromServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServingConfigName', () => { - const result = client.matchLocationFromServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromServingConfigName', () => { - const result = client.matchCatalogFromServingConfigName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromServingConfigName', () => { - const result = client.matchServingConfigFromServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.servingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2beta/tsconfig.json b/owl-bot-staging/v2beta/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v2beta/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/v2beta/webpack.config.js b/owl-bot-staging/v2beta/webpack.config.js deleted file mode 100644 index f2c58f25..00000000 --- a/owl-bot-staging/v2beta/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: 'CatalogService', - filename: './catalog-service.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/protos/google/cloud/retail/v2/catalog.proto b/protos/google/cloud/retail/v2/catalog.proto index b5de698d..119afaf3 100644 --- a/protos/google/cloud/retail/v2/catalog.proto +++ b/protos/google/cloud/retail/v2/catalog.proto @@ -40,10 +40,10 @@ message ProductLevelConfig { // default to // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] if // unset. - // * `variant`: You can only ingest - // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] - // [Product][google.cloud.retail.v2.Product]s. - // This means + // * `variant` (incompatible with Retail Search): You can only + // ingest + // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. This means // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] // cannot be empty. // @@ -54,8 +54,8 @@ message ProductLevelConfig { // [merchant_center_product_id_field][google.cloud.retail.v2.ProductLevelConfig.merchant_center_product_id_field] // is `itemGroupId`, an INVALID_ARGUMENT error is returned. // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) // for more details. string ingestion_product_type = 1; @@ -76,8 +76,8 @@ message ProductLevelConfig { // [ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] // is `variant`, an INVALID_ARGUMENT error is returned. // - // See [Using product - // levels](https://cloud.google.com/retail/recommendations-ai/docs/catalog#product-levels) + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) // for more details. string merchant_center_product_id_field = 2; } diff --git a/protos/google/cloud/retail/v2/common.proto b/protos/google/cloud/retail/v2/common.proto index 733b8cca..386a9aa6 100644 --- a/protos/google/cloud/retail/v2/common.proto +++ b/protos/google/cloud/retail/v2/common.proto @@ -115,24 +115,29 @@ message CustomAttribute { // Otherwise, an INVALID_ARGUMENT error is returned. repeated double numbers = 2; - // This field will only be used when + // This field is normally ignored unless // [AttributesConfig.attribute_config_level][] of the - // [Catalog][google.cloud.retail.v2.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // searchable by text queries in + // [Catalog][google.cloud.retail.v2.Catalog] is set to the deprecated + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level + // attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are searchable by text queries in // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. // // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. // // Only set if type [text][google.cloud.retail.v2.CustomAttribute.text] is // set. Otherwise, a INVALID_ARGUMENT error is returned. - optional bool searchable = 3; + optional bool searchable = 3 [deprecated = true]; - // This field will only be used when + // This field is normally ignored unless // [AttributesConfig.attribute_config_level][] of the - // [Catalog][google.cloud.retail.v2.Catalog] is - // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG', if true, custom attribute values are - // indexed, so that it can be filtered, faceted or boosted in + // [Catalog][google.cloud.retail.v2.Catalog] is set to the deprecated + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level + // attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are indexed, so that they can be filtered, + // faceted or boosted in // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. // // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. @@ -142,7 +147,7 @@ message CustomAttribute { // and // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] // for more details. - optional bool indexable = 4; + optional bool indexable = 4 [deprecated = true]; } // Fulfillment information, such as the store IDs for in-store pickup or region @@ -284,7 +289,10 @@ message PriceInfo { float price = 2; // Price of the product without any discount. If zero, by default set to be - // the [price][google.cloud.retail.v2.PriceInfo.price]. + // the [price][google.cloud.retail.v2.PriceInfo.price]. If set, + // [original_price][google.cloud.retail.v2.PriceInfo.original_price] should be + // greater than or equal to [price][google.cloud.retail.v2.PriceInfo.price], + // otherwise an INVALID_ARGUMENT error is thrown. float original_price = 3; // The costs associated with the sale of a particular product. Used for gross @@ -368,10 +376,14 @@ message Rating { // Information of an end user. message UserInfo { // Highly recommended for logged-in users. Unique identifier for logged-in - // user, such as a user name. + // user, such as a user name. Don't set for anonymous users. // // Always use a hashed value for this ID. // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded + // model quality. + // // The field must be a UTF-8 encoded string with a length limit of 128 // characters. Otherwise, an INVALID_ARGUMENT error is returned. string user_id = 1; diff --git a/protos/google/cloud/retail/v2/completion_service.proto b/protos/google/cloud/retail/v2/completion_service.proto index 5e7e9a6c..68306218 100644 --- a/protos/google/cloud/retail/v2/completion_service.proto +++ b/protos/google/cloud/retail/v2/completion_service.proto @@ -133,9 +133,9 @@ message CompleteQueryRequest { // // * user-data // - // * cloud-retail - // This option requires additional allowlisting. Before using cloud-retail, - // contact Cloud Retail support team first. + // * cloud-retail: + // This option requires enabling auto-learning function first. See + // [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). string dataset = 6; // Completion max suggestions. If left unset or set to 0, then will fallback @@ -154,10 +154,13 @@ message CompleteQueryResponse { string suggestion = 1; // Custom attributes for the suggestion term. + // // * For "user-data", the attributes are additional custom attributes // ingested through BigQuery. + // // * For "cloud-retail", the attributes are product attributes generated - // by Cloud Retail. + // by Cloud Retail. This is an experimental feature. Contact Retail Search + // support team if you are interested in enabling it. map attributes = 2; } @@ -185,11 +188,15 @@ message CompleteQueryResponse { // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2.CompleteQueryRequest.visitor_id] // field is set and [UserEvent][google.cloud.retail.v2.UserEvent] is imported. // The recent searches satisfy the follow rules: + // // * They are ordered from latest to oldest. + // // * They are matched with // [CompleteQueryRequest.query][google.cloud.retail.v2.CompleteQueryRequest.query] // case insensitively. + // // * They are transformed to lower cases. + // // * They are UTF-8 safe. // // Recent searches are deduplicated. More recent searches will be reserved diff --git a/protos/google/cloud/retail/v2/import_config.proto b/protos/google/cloud/retail/v2/import_config.proto index 74cec22a..cadec119 100644 --- a/protos/google/cloud/retail/v2/import_config.proto +++ b/protos/google/cloud/retail/v2/import_config.proto @@ -214,11 +214,18 @@ message ImportProductsRequest { // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. ReconciliationMode reconciliation_mode = 5; - // Pub/Sub topic for receiving notification. If this field is set, + // Full Pub/Sub topic name for receiving notification. If this field is set, // when the import is finished, a notification will be sent to // specified Pub/Sub topic. The message data will be JSON string of a // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + // + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + // to be within the same project as + // [ImportProductsRequest.parent][google.cloud.retail.v2.ImportProductsRequest.parent]. + // Make sure that both + // `cloud-retail-customer-data-access@system.gserviceaccount.com` and + // `service-@gcp-sa-retail.iam.gserviceaccount.com` + // have the `pubsub.topics.publish` IAM permission on the topic. // // Only supported when // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode] diff --git a/protos/google/cloud/retail/v2/prediction_service.proto b/protos/google/cloud/retail/v2/prediction_service.proto index 061db142..f1f1b4e1 100644 --- a/protos/google/cloud/retail/v2/prediction_service.proto +++ b/protos/google/cloud/retail/v2/prediction_service.proto @@ -63,6 +63,16 @@ message PredictRequest { // they took to trigger the predict request. Note that this user event detail // won't be ingested to userEvent logs. Thus, a separate userEvent write // request is required for event logging. + // + // Don't set + // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id] or + // [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id] to the same + // fixed ID for different users. If you are trying to receive non-personalized + // recommendations (not recommended; this can negatively impact model + // performance), instead set + // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id] to a + // random unique ID and leave + // [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id] unset. UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; // Maximum number of results to return per page. Set this property @@ -143,7 +153,7 @@ message PredictRequest { // * Each resource can have multiple labels, up to a maximum of 64. // * Each label must be a key-value pair. // * Keys have a minimum length of 1 character and a maximum length of 63 - // characters, and cannot be empty. Values can be empty, and have a maximum + // characters and cannot be empty. Values can be empty and have a maximum // length of 63 characters. // * Keys and values can contain only lowercase letters, numeric characters, // underscores, and dashes. All characters must use UTF-8 encoding, and @@ -169,9 +179,9 @@ message PredictResponse { // // Possible values: // - // * `product`: JSON representation of the product. Will be set if + // * `product`: JSON representation of the product. Is set if // `returnProduct` is set to true in `PredictRequest.params`. - // * `score`: Prediction score in double value. Will be set if + // * `score`: Prediction score in double value. Is set if // `returnScore` is set to true in `PredictRequest.params`. map metadata = 2; } diff --git a/protos/google/cloud/retail/v2/product.proto b/protos/google/cloud/retail/v2/product.proto index ea861fb6..43443295 100644 --- a/protos/google/cloud/retail/v2/product.proto +++ b/protos/google/cloud/retail/v2/product.proto @@ -536,11 +536,11 @@ message Product { // * [name][google.cloud.retail.v2.Product.name] // * [color_info][google.cloud.retail.v2.Product.color_info] // - // Maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is // returned. // // Note: Returning more fields in - // [SearchResponse][google.cloud.retail.v2.SearchResponse] may increase + // [SearchResponse][google.cloud.retail.v2.SearchResponse] can increase // response payload size and serving latency. google.protobuf.FieldMask retrievable_fields = 30; diff --git a/protos/google/cloud/retail/v2/product_service.proto b/protos/google/cloud/retail/v2/product_service.proto index 71319834..ba8d8d18 100644 --- a/protos/google/cloud/retail/v2/product_service.proto +++ b/protos/google/cloud/retail/v2/product_service.proto @@ -88,7 +88,7 @@ service ProductService { // Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. // - // Request processing may be synchronous. No partial updating is supported. + // Request processing may be synchronous. // Non-existing items are created. // // Note that it is possible for a subset of the @@ -139,7 +139,7 @@ service ProductService { // // Pre-existing inventory information can only be updated with // [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], - // [AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], // and // [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. // @@ -345,6 +345,11 @@ message UpdateProductRequest { // // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error // is returned. + // + // The attribute key can be updated by setting the mask path as + // "attributes.${key_name}". If a key name is present in the mask but not in + // the patching product from the request, this key will be deleted after the + // update. google.protobuf.FieldMask update_mask = 2; // If set to true, and the [Product][google.cloud.retail.v2.Product] is not @@ -572,7 +577,9 @@ message SetInventoryMetadata {} // method. message SetInventoryResponse {} -// Request message for [AddFulfillmentPlaces][] method. +// Request message for +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] +// method. message AddFulfillmentPlacesRequest { // Required. Full resource name of [Product][google.cloud.retail.v2.Product], // such as @@ -640,15 +647,19 @@ message AddFulfillmentPlacesRequest { // Metadata related to the progress of the AddFulfillmentPlaces operation. // Currently empty because there is no meaningful metadata populated from the -// [AddFulfillmentPlaces][] method. +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] +// method. message AddFulfillmentPlacesMetadata {} // Response of the AddFulfillmentPlacesRequest. Currently empty because -// there is no meaningful response populated from the [AddFulfillmentPlaces][] +// there is no meaningful response populated from the +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] // method. message AddFulfillmentPlacesResponse {} -// Request message for [AddLocalInventories][] method. +// Request message for +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// method. message AddLocalInventoriesRequest { // Required. Full resource name of [Product][google.cloud.retail.v2.Product], // such as @@ -700,11 +711,15 @@ message AddLocalInventoriesRequest { // Metadata related to the progress of the AddLocalInventories operation. // Currently empty because there is no meaningful metadata populated from the -// [AddLocalInventories][] method. +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// method. message AddLocalInventoriesMetadata {} -// Response of the [AddLocalInventories][] API. Currently empty because -// there is no meaningful response populated from the [AddLocalInventories][] +// Response of the +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] // method. message AddLocalInventoriesResponse {} @@ -782,7 +797,8 @@ message RemoveFulfillmentPlacesRequest { // If this field is set to an invalid value other than these, an // INVALID_ARGUMENT error is returned. // - // This field directly corresponds to [Product.fulfillment_info.type][]. + // This field directly corresponds to + // [Product.fulfillment_info.type][google.cloud.retail.v2.FulfillmentInfo.type]. string type = 2 [(google.api.field_behavior) = REQUIRED]; // Required. The IDs for this diff --git a/protos/google/cloud/retail/v2/purge_config.proto b/protos/google/cloud/retail/v2/purge_config.proto index 6c8d54c7..cb510745 100644 --- a/protos/google/cloud/retail/v2/purge_config.proto +++ b/protos/google/cloud/retail/v2/purge_config.proto @@ -37,7 +37,10 @@ message PurgeUserEventsRequest { // Required. The resource name of the catalog under which the events are // created. The format is // `projects/${projectId}/locations/global/catalogs/${catalogId}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; // Required. The filter string to specify the events to be deleted with a // length limit of 5,000 characters. Empty string filter is not allowed. The diff --git a/protos/google/cloud/retail/v2/search_service.proto b/protos/google/cloud/retail/v2/search_service.proto index ec8750ae..82242742 100644 --- a/protos/google/cloud/retail/v2/search_service.proto +++ b/protos/google/cloud/retail/v2/search_service.proto @@ -113,8 +113,8 @@ message SearchRequest { // Only get facet for the given restricted values. For example, when using // "pickupInStore" as key and set restricted values to // ["store123", "store456"], only facets for "store123" and "store456" are - // returned. Only supported on textual fields and fulfillments. - // Maximum is 20. + // returned. Only supported on predefined textual fields, custom textual + // attributes and fulfillments. Maximum is 20. // // Must be set for the fulfillment facet keys: // @@ -206,19 +206,29 @@ message SearchRequest { // List of keys to exclude when faceting. // + // // By default, // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] // is not excluded from the filter unless it is listed in this field. // - // For example, suppose there are 100 products with color facet "Red" and - // 200 products with color facet "Blue". A query containing the filter - // "colorFamilies:ANY("Red")" and have "colorFamilies" as + // Listing a facet key in this field allows its values to appear as facet + // results, even when they are filtered out of search results. Using this + // field does not affect what search results are returned. + // + // For example, suppose there are 100 products with the color facet "Red" + // and 200 products with the color facet "Blue". A query containing the + // filter "colorFamilies:ANY("Red")" and having "colorFamilies" as // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] - // will by default return the "Red" with count 100. + // would by default return only "Red" products in the search results, and + // also return "Red" with count 100 as the only color facet. Although there + // are also blue products available, "Blue" would not be shown as an + // available facet value. // - // If this field contains "colorFamilies", then the query returns both the - // "Red" with count 100 and "Blue" with count 200, because the - // "colorFamilies" key is now excluded from the filter. + // If "colorFamilies" is listed in "excludedFilterKeys", then the query + // returns the facet values "Red" with count 100 and "Blue" with count + // 200, because the "colorFamilies" key is now excluded from the filter. + // Because this field doesn't affect search results, the search results + // are still correctly filtered to return only "Red" products. // // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error // is returned. @@ -317,7 +327,7 @@ message SearchRequest { // Condition boost specifications. If a product matches multiple conditions // in the specifictions, boost scores from these specifications are all // applied and combined in a non-linear way. Maximum number of - // specifications is 10. + // specifications is 20. repeated ConditionBoostSpec condition_boost_specs = 1; // Whether to skip boostspec validation. If this field is set to true, @@ -377,6 +387,31 @@ message SearchRequest { Mode mode = 1; } + // The specification for query spell correction. + message SpellCorrectionSpec { + // Enum describing under which mode spell correction should occur. + enum Mode { + // Unspecified spell correction mode. This defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Google Retail Search will try to find a spell suggestion if there + // is any and put in the + // [SearchResponse.corrected_query][google.cloud.retail.v2.SearchResponse.corrected_query]. + // The spell suggestion will not be used as the search query. + SUGGESTION_ONLY = 1; + + // Automatic spell correction built by Google Retail Search. Search will + // be based on the corrected query if found. + AUTO = 2; + } + + // The mode under which spell correction should take effect to + // replace the original search query. Default to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + Mode mode = 1; + } + // The search mode of each search request. enum SearchMode { // Default value. In this case both product search and faceted search will @@ -398,7 +433,9 @@ message SearchRequest { // Only faceted search will be performed. The product search will be // disabled. // - // When in this mode, one or both of [SearchRequest.facet_spec][] and + // When in this mode, one or both of + // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] + // and // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] @@ -407,7 +444,7 @@ message SearchRequest { } // Required. The resource name of the search engine placement, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search` + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. // This field is used to identify the serving configuration name and the set // of models that will be used to make the search. string placement = 1 [(google.api.field_behavior) = REQUIRED]; @@ -422,6 +459,11 @@ message SearchRequest { ]; // Raw search query. + // + // If this field is empty, the request is considered a category browsing + // request and returned results are based on + // [filter][google.cloud.retail.v2.SearchRequest.filter] and + // [page_categories][google.cloud.retail.v2.SearchRequest.page_categories]. string query = 3; // Required. A unique identifier for tracking visitors. For example, this @@ -515,10 +557,10 @@ message SearchRequest { // [user guide](https://cloud.google.com/retail/docs/boosting). // // Notice that if both [ServingConfig.boost_control_ids][] and - // [SearchRequest.boost_spec] are set, the boost conditions from both places - // are evaluated. If a search request matches multiple boost conditions, - // the final boost score is equal to the sum of the boost scores from all - // matched boost conditions. + // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] + // are set, the boost conditions from both places are evaluated. If a search + // request matches multiple boost conditions, the final boost score is equal + // to the sum of the boost scores from all matched boost conditions. BoostSpec boost_spec = 13; // The query expansion specification that specifies the conditions under which @@ -553,7 +595,8 @@ message SearchRequest { // * inventory(place_id,price) // * inventory(place_id,original_price) // * inventory(place_id,attributes.key), where key is any key in the - // [Product.inventories.attributes][] map. + // [Product.local_inventories.attributes][google.cloud.retail.v2.LocalInventory.attributes] + // map. // * attributes.key, where key is any key in the // [Product.attributes][google.cloud.retail.v2.Product.attributes] map. // * pickupInStore.id, where id is any @@ -617,6 +660,29 @@ message SearchRequest { // The specification for personalization. PersonalizationSpec personalization_spec = 32; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters and cannot be empty. Values can be empty and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 34; + + // The spell correction specification that specifies the mode under + // which spell correction will take effect. + optional SpellCorrectionSpec spell_correction_spec = 35; } // Response message for @@ -750,7 +816,9 @@ message SearchResponse { // matches. int32 total_size = 3; - // If spell correction applies, the corrected query. Otherwise, empty. + // Contains the spell corrected query, if found. If the spell correction type + // is AUTOMATIC, then the search results are based on corrected_query. + // Otherwise the original query will be used for search. string corrected_query = 4; // A unique search token. This should be included in the @@ -768,10 +836,10 @@ message SearchResponse { QueryExpansionInfo query_expansion_info = 7; // The URI of a customer-defined redirect page. If redirect action is - // triggered, no search will be performed, and only + // triggered, no search is performed, and only // [redirect_uri][google.cloud.retail.v2.SearchResponse.redirect_uri] and // [attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] - // will be set in the response. + // are set in the response. string redirect_uri = 10; // The fully qualified resource name of applied diff --git a/protos/google/cloud/retail/v2/user_event.proto b/protos/google/cloud/retail/v2/user_event.proto index 8e21f8aa..fc315f88 100644 --- a/protos/google/cloud/retail/v2/user_event.proto +++ b/protos/google/cloud/retail/v2/user_event.proto @@ -54,11 +54,15 @@ message UserEvent { // able to uniquely identify a visitor on a single device. This unique // identifier should not change if the visitor log in/out of the website. // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded model + // quality. + // // The field must be a UTF-8 encoded string with a length limit of 128 // characters. Otherwise, an INVALID_ARGUMENT error is returned. // // The field should not contain PII or user-data. We recommend to use Google - // Analystics [Client + // Analytics [Client // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) // for this field. string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; @@ -111,12 +115,11 @@ message UserEvent { // The main product details related to the event. // - // This field is required for the following event types: + // This field is optional except for the following event types: // // * `add-to-cart` // * `detail-page-view` // * `purchase-complete` - // * `search` // // In a `search` event, this field represents the products returned to the end // user on the current page (the end user may have not finished browsing the diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 2e6a9dfa..d535c5a5 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -8131,6 +8131,12 @@ export namespace google { /** SearchRequest personalizationSpec */ personalizationSpec?: (google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null); + + /** SearchRequest labels */ + labels?: ({ [k: string]: string }|null); + + /** SearchRequest spellCorrectionSpec */ + spellCorrectionSpec?: (google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec|null); } /** Represents a SearchRequest. */ @@ -8199,6 +8205,15 @@ export namespace google { /** SearchRequest personalizationSpec. */ public personalizationSpec?: (google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null); + /** SearchRequest labels. */ + public labels: { [k: string]: string }; + + /** SearchRequest spellCorrectionSpec. */ + public spellCorrectionSpec?: (google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec|null); + + /** SearchRequest _spellCorrectionSpec. */ + public _spellCorrectionSpec?: "spellCorrectionSpec"; + /** * Creates a new SearchRequest instance using the specified properties. * @param [properties] Properties to set @@ -9013,6 +9028,106 @@ export namespace google { } } + /** Properties of a SpellCorrectionSpec. */ + interface ISpellCorrectionSpec { + + /** SpellCorrectionSpec mode */ + mode?: (google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode|keyof typeof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode|null); + } + + /** Represents a SpellCorrectionSpec. */ + class SpellCorrectionSpec implements ISpellCorrectionSpec { + + /** + * Constructs a new SpellCorrectionSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec); + + /** SpellCorrectionSpec mode. */ + public mode: (google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode|keyof typeof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode); + + /** + * Creates a new SpellCorrectionSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns SpellCorrectionSpec instance + */ + public static create(properties?: google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec): google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec; + + /** + * Encodes the specified SpellCorrectionSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @param message SpellCorrectionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpellCorrectionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @param message SpellCorrectionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec; + + /** + * Verifies a SpellCorrectionSpec message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SpellCorrectionSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpellCorrectionSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec; + + /** + * Creates a plain object from a SpellCorrectionSpec message. Also converts values to other types if specified. + * @param message SpellCorrectionSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpellCorrectionSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace SpellCorrectionSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + SUGGESTION_ONLY = 1, + AUTO = 2 + } + } + /** SearchMode enum. */ enum SearchMode { SEARCH_MODE_UNSPECIFIED = 0, diff --git a/protos/protos.js b/protos/protos.js index 6fbed5b5..a3d00834 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -19705,6 +19705,8 @@ * @property {Array.|null} [pageCategories] SearchRequest pageCategories * @property {google.cloud.retail.v2.SearchRequest.SearchMode|null} [searchMode] SearchRequest searchMode * @property {google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null} [personalizationSpec] SearchRequest personalizationSpec + * @property {Object.|null} [labels] SearchRequest labels + * @property {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec|null} [spellCorrectionSpec] SearchRequest spellCorrectionSpec */ /** @@ -19719,6 +19721,7 @@ this.facetSpecs = []; this.variantRollupKeys = []; this.pageCategories = []; + this.labels = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -19877,6 +19880,36 @@ */ SearchRequest.prototype.personalizationSpec = null; + /** + * SearchRequest labels. + * @member {Object.} labels + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.labels = $util.emptyObject; + + /** + * SearchRequest spellCorrectionSpec. + * @member {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec|null|undefined} spellCorrectionSpec + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.spellCorrectionSpec = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * SearchRequest _spellCorrectionSpec. + * @member {"spellCorrectionSpec"|undefined} _spellCorrectionSpec + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + Object.defineProperty(SearchRequest.prototype, "_spellCorrectionSpec", { + get: $util.oneOfGetter($oneOfFields = ["spellCorrectionSpec"]), + set: $util.oneOfSetter($oneOfFields) + }); + /** * Creates a new SearchRequest instance using the specified properties. * @function create @@ -19942,6 +19975,11 @@ writer.uint32(/* id 31, wireType 0 =*/248).int32(message.searchMode); if (message.personalizationSpec != null && Object.hasOwnProperty.call(message, "personalizationSpec")) $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.encode(message.personalizationSpec, writer.uint32(/* id 32, wireType 2 =*/258).fork()).ldelim(); + if (message.labels != null && Object.hasOwnProperty.call(message, "labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 34, wireType 2 =*/274).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + if (message.spellCorrectionSpec != null && Object.hasOwnProperty.call(message, "spellCorrectionSpec")) + $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.encode(message.spellCorrectionSpec, writer.uint32(/* id 35, wireType 2 =*/282).fork()).ldelim(); return writer; }; @@ -19972,7 +20010,7 @@ SearchRequest.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.retail.v2.SearchRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.retail.v2.SearchRequest(), key, value; while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { @@ -20039,6 +20077,31 @@ case 32: message.personalizationSpec = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.decode(reader, reader.uint32()); break; + case 34: + if (message.labels === $util.emptyObject) + message.labels = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.labels[key] = value; + break; + case 35: + message.spellCorrectionSpec = $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.decode(reader, reader.uint32()); + break; default: reader.skipType(tag & 7); break; @@ -20074,6 +20137,7 @@ SearchRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; + var properties = {}; if (message.placement != null && message.hasOwnProperty("placement")) if (!$util.isString(message.placement)) return "placement: string expected"; @@ -20161,6 +20225,22 @@ if (error) return "personalizationSpec." + error; } + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + if (message.spellCorrectionSpec != null && message.hasOwnProperty("spellCorrectionSpec")) { + properties._spellCorrectionSpec = 1; + { + var error = $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify(message.spellCorrectionSpec); + if (error) + return "spellCorrectionSpec." + error; + } + } return null; }; @@ -20259,6 +20339,18 @@ throw TypeError(".google.cloud.retail.v2.SearchRequest.personalizationSpec: object expected"); message.personalizationSpec = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.fromObject(object.personalizationSpec); } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + if (object.spellCorrectionSpec != null) { + if (typeof object.spellCorrectionSpec !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.spellCorrectionSpec: object expected"); + message.spellCorrectionSpec = $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.fromObject(object.spellCorrectionSpec); + } return message; }; @@ -20280,6 +20372,8 @@ object.variantRollupKeys = []; object.pageCategories = []; } + if (options.objects || options.defaults) + object.labels = {}; if (options.defaults) { object.placement = ""; object.branch = ""; @@ -20345,6 +20439,17 @@ object.searchMode = options.enums === String ? $root.google.cloud.retail.v2.SearchRequest.SearchMode[message.searchMode] : message.searchMode; if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) object.personalizationSpec = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.toObject(message.personalizationSpec, options); + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + if (message.spellCorrectionSpec != null && message.hasOwnProperty("spellCorrectionSpec")) { + object.spellCorrectionSpec = $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.toObject(message.spellCorrectionSpec, options); + if (options.oneofs) + object._spellCorrectionSpec = "spellCorrectionSpec"; + } return object; }; @@ -22171,6 +22276,227 @@ return PersonalizationSpec; })(); + SearchRequest.SpellCorrectionSpec = (function() { + + /** + * Properties of a SpellCorrectionSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @interface ISpellCorrectionSpec + * @property {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode|null} [mode] SpellCorrectionSpec mode + */ + + /** + * Constructs a new SpellCorrectionSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @classdesc Represents a SpellCorrectionSpec. + * @implements ISpellCorrectionSpec + * @constructor + * @param {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec=} [properties] Properties to set + */ + function SpellCorrectionSpec(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SpellCorrectionSpec mode. + * @member {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode} mode + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @instance + */ + SpellCorrectionSpec.prototype.mode = 0; + + /** + * Creates a new SpellCorrectionSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec instance + */ + SpellCorrectionSpec.create = function create(properties) { + return new SpellCorrectionSpec(properties); + }; + + /** + * Encodes the specified SpellCorrectionSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec} message SpellCorrectionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpellCorrectionSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified SpellCorrectionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec} message SpellCorrectionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpellCorrectionSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpellCorrectionSpec.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mode = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpellCorrectionSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpellCorrectionSpec message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpellCorrectionSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a SpellCorrectionSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + */ + SpellCorrectionSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec(); + switch (object.mode) { + case "MODE_UNSPECIFIED": + case 0: + message.mode = 0; + break; + case "SUGGESTION_ONLY": + case 1: + message.mode = 1; + break; + case "AUTO": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a SpellCorrectionSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} message SpellCorrectionSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpellCorrectionSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this SpellCorrectionSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @instance + * @returns {Object.} JSON object + */ + SpellCorrectionSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} SUGGESTION_ONLY=1 SUGGESTION_ONLY value + * @property {number} AUTO=2 AUTO value + */ + SpellCorrectionSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SUGGESTION_ONLY"] = 1; + values[valuesById[2] = "AUTO"] = 2; + return values; + })(); + + return SpellCorrectionSpec; + })(); + /** * SearchMode enum. * @name google.cloud.retail.v2.SearchRequest.SearchMode diff --git a/protos/protos.json b/protos/protos.json index daf9f12a..9454ba85 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -305,6 +305,7 @@ "type": "bool", "id": 3, "options": { + "deprecated": true, "proto3_optional": true } }, @@ -312,6 +313,7 @@ "type": "bool", "id": 4, "options": { + "deprecated": true, "proto3_optional": true } } @@ -2007,7 +2009,8 @@ "type": "string", "id": 1, "options": { - "(google.api.field_behavior)": "REQUIRED" + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" } }, "filter": { @@ -2056,6 +2059,13 @@ } }, "SearchRequest": { + "oneofs": { + "_spellCorrectionSpec": { + "oneof": [ + "spellCorrectionSpec" + ] + } + }, "fields": { "placement": { "type": "string", @@ -2147,6 +2157,18 @@ "personalizationSpec": { "type": "PersonalizationSpec", "id": 32 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 34 + }, + "spellCorrectionSpec": { + "type": "SpellCorrectionSpec", + "id": 35, + "options": { + "proto3_optional": true + } } }, "nested": { @@ -2307,6 +2329,23 @@ } } }, + "SpellCorrectionSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "SUGGESTION_ONLY": 1, + "AUTO": 2 + } + } + } + }, "SearchMode": { "values": { "SEARCH_MODE_UNSPECIFIED": 0, diff --git a/samples/generated/v2/completion_service.complete_query.js b/samples/generated/v2/completion_service.complete_query.js index 738d1b40..51c1efcd 100644 --- a/samples/generated/v2/completion_service.complete_query.js +++ b/samples/generated/v2/completion_service.complete_query.js @@ -74,9 +74,9 @@ function main(catalog, query) { * events. If leave empty, it will use the "user-data". * Current supported values: * * user-data - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * guidelines (https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). */ // const dataset = 'abc123' /** diff --git a/samples/generated/v2/prediction_service.predict.js b/samples/generated/v2/prediction_service.predict.js index af3de619..d2db6c72 100644 --- a/samples/generated/v2/prediction_service.predict.js +++ b/samples/generated/v2/prediction_service.predict.js @@ -41,6 +41,15 @@ function main(placement, userEvent) { * they took to trigger the predict request. Note that this user event detail * won't be ingested to userEvent logs. Thus, a separate userEvent write * request is required for event logging. + * Don't set + * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id or + * UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id to the same + * fixed ID for different users. If you are trying to receive non-personalized + * recommendations (not recommended; this can negatively impact model + * performance), instead set + * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id to a + * random unique ID and leave + * UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id unset. */ // const userEvent = {} /** @@ -118,7 +127,7 @@ function main(placement, userEvent) { * * Each resource can have multiple labels, up to a maximum of 64. * * Each label must be a key-value pair. * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum + * characters and cannot be empty. Values can be empty and have a maximum * length of 63 characters. * * Keys and values can contain only lowercase letters, numeric characters, * underscores, and dashes. All characters must use UTF-8 encoding, and diff --git a/samples/generated/v2/product_service.import_products.js b/samples/generated/v2/product_service.import_products.js index 39cc5522..3de37997 100644 --- a/samples/generated/v2/product_service.import_products.js +++ b/samples/generated/v2/product_service.import_products.js @@ -52,11 +52,17 @@ function main(parent, inputConfig) { */ // const reconciliationMode = {} /** - * Pub/Sub topic for receiving notification. If this field is set, + * Full Pub/Sub topic name for receiving notification. If this field is set, * when the import is finished, a notification will be sent to * specified Pub/Sub topic. The message data will be JSON string of a * Operation google.longrunning.Operation. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * ImportProductsRequest.parent google.cloud.retail.v2.ImportProductsRequest.parent. + * Make sure that both + * `cloud-retail-customer-data-access@system.gserviceaccount.com` and + * `service-@gcp-sa-retail.iam.gserviceaccount.com` + * have the `pubsub.topics.publish` IAM permission on the topic. * Only supported when * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode * is set to `FULL`. diff --git a/samples/generated/v2/product_service.remove_fulfillment_places.js b/samples/generated/v2/product_service.remove_fulfillment_places.js index 3be188b8..8824fefa 100644 --- a/samples/generated/v2/product_service.remove_fulfillment_places.js +++ b/samples/generated/v2/product_service.remove_fulfillment_places.js @@ -49,7 +49,8 @@ function main(product, type, placeIds) { * * "custom-type-5" * If this field is set to an invalid value other than these, an * INVALID_ARGUMENT error is returned. - * This field directly corresponds to Product.fulfillment_info.type . + * This field directly corresponds to + * Product.fulfillment_info.type google.cloud.retail.v2.FulfillmentInfo.type. */ // const type = 'abc123' /** diff --git a/samples/generated/v2/product_service.update_product.js b/samples/generated/v2/product_service.update_product.js index 359a30ef..7c7a9f41 100644 --- a/samples/generated/v2/product_service.update_product.js +++ b/samples/generated/v2/product_service.update_product.js @@ -43,6 +43,10 @@ function main(product) { * fields that are neither immutable nor output only) are updated. * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error * is returned. + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. */ // const updateMask = {} /** diff --git a/samples/generated/v2/search_service.search.js b/samples/generated/v2/search_service.search.js index 2083811f..26118e14 100644 --- a/samples/generated/v2/search_service.search.js +++ b/samples/generated/v2/search_service.search.js @@ -27,7 +27,7 @@ function main(placement, visitorId) { */ /** * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. * This field is used to identify the serving configuration name and the set * of models that will be used to make the search. */ @@ -41,6 +41,10 @@ function main(placement, visitorId) { // const branch = 'abc123' /** * Raw search query. + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * filter google.cloud.retail.v2.SearchRequest.filter and + * page_categories google.cloud.retail.v2.SearchRequest.page_categories. */ // const query = 'abc123' /** @@ -126,10 +130,10 @@ function main(placement, visitorId) { * Boost specification to boost certain products. See more details at this * user guide (https://cloud.google.com/retail/docs/boosting). * Notice that if both ServingConfig.boost_control_ids and - * SearchRequest.boost_spec are set, the boost conditions from both places - * are evaluated. If a search request matches multiple boost conditions, - * the final boost score is equal to the sum of the boost scores from all - * matched boost conditions. + * SearchRequest.boost_spec google.cloud.retail.v2.SearchRequest.boost_spec + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. */ // const boostSpec = {} /** @@ -163,7 +167,8 @@ function main(placement, visitorId) { * * inventory(place_id,price) * * inventory(place_id,original_price) * * inventory(place_id,attributes.key), where key is any key in the - * Product.inventories.attributes map. + * Product.local_inventories.attributes google.cloud.retail.v2.LocalInventory.attributes + * map. * * attributes.key, where key is any key in the * Product.attributes google.cloud.retail.v2.Product.attributes map. * * pickupInStore.id, where id is any @@ -228,6 +233,29 @@ function main(placement, visitorId) { * The specification for personalization. */ // const personalizationSpec = {} + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + */ + // const spellCorrectionSpec = {} // Imports the Retail library const {SearchServiceClient} = require('@google-cloud/retail').v2; diff --git a/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json b/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json index 7949361c..2d159003 100644 --- a/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json +++ b/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json @@ -318,7 +318,7 @@ "segments": [ { "start": 25, - "end": 153, + "end": 162, "type": "FULL" } ], @@ -530,7 +530,7 @@ "segments": [ { "start": 25, - "end": 72, + "end": 76, "type": "FULL" } ], @@ -611,14 +611,14 @@ "regionTag": "retail_v2_generated_ProductService_ImportProducts_async", "title": "CatalogService importProducts Sample", "origin": "API_DEFINITION", - "description": " Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. Request processing may be synchronous. No partial updating is supported. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2.Product]s to be successfully updated.", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. Request processing may be synchronous. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2.Product]s to be successfully updated.", "canonical": true, "file": "product_service.import_products.js", "language": "JAVASCRIPT", "segments": [ { "start": 25, - "end": 85, + "end": 91, "type": "FULL" } ], @@ -675,7 +675,7 @@ "regionTag": "retail_v2_generated_ProductService_SetInventory_async", "title": "CatalogService setInventory Sample", "origin": "API_DEFINITION", - "description": " Updates inventory information for a [Product][google.cloud.retail.v2.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], [AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. When inventory is updated with [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or [UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [SetInventory][google.cloud.retail.v2.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], and [RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", "canonical": true, "file": "product_service.set_inventory.js", "language": "JAVASCRIPT", @@ -790,7 +790,7 @@ "segments": [ { "start": 25, - "end": 103, + "end": 104, "type": "FULL" } ], @@ -954,7 +954,7 @@ "segments": [ { "start": 25, - "end": 252, + "end": 280, "type": "FULL" } ], @@ -1038,6 +1038,14 @@ { "name": "personalization_spec", "type": ".google.cloud.retail.v2.SearchRequest.PersonalizationSpec" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "spell_correction_spec", + "type": ".google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec" } ], "resultType": ".google.cloud.retail.v2.SearchResponse", diff --git a/src/v2/completion_service_client.ts b/src/v2/completion_service_client.ts index ceec448c..2cdbab92 100644 --- a/src/v2/completion_service_client.ts +++ b/src/v2/completion_service_client.ts @@ -392,9 +392,9 @@ export class CompletionServiceClient { * * * user-data * - * * cloud-retail - * This option requires additional allowlisting. Before using cloud-retail, - * contact Cloud Retail support team first. + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). * @param {number} request.maxSuggestions * Completion max suggestions. If left unset or set to 0, then will fallback * to the configured value {@link |CompletionConfig.max_suggestions}. diff --git a/src/v2/prediction_service_client.ts b/src/v2/prediction_service_client.ts index 436b568e..1aa966c6 100644 --- a/src/v2/prediction_service_client.ts +++ b/src/v2/prediction_service_client.ts @@ -314,6 +314,16 @@ export class PredictionServiceClient { * they took to trigger the predict request. Note that this user event detail * won't be ingested to userEvent logs. Thus, a separate userEvent write * request is required for event logging. + * + * Don't set + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link google.cloud.retail.v2.UserInfo.user_id|UserInfo.user_id} to the same + * fixed ID for different users. If you are trying to receive non-personalized + * recommendations (not recommended; this can negatively impact model + * performance), instead set + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} to a + * random unique ID and leave + * {@link google.cloud.retail.v2.UserInfo.user_id|UserInfo.user_id} unset. * @param {number} request.pageSize * Maximum number of results to return per page. Set this property * to the number of prediction results needed. If zero, the service will @@ -388,7 +398,7 @@ export class PredictionServiceClient { * * Each resource can have multiple labels, up to a maximum of 64. * * Each label must be a key-value pair. * * Keys have a minimum length of 1 character and a maximum length of 63 - * characters, and cannot be empty. Values can be empty, and have a maximum + * characters and cannot be empty. Values can be empty and have a maximum * length of 63 characters. * * Keys and values can contain only lowercase letters, numeric characters, * underscores, and dashes. All characters must use UTF-8 encoding, and diff --git a/src/v2/product_service_client.ts b/src/v2/product_service_client.ts index 5c4d892a..7e91e71a 100644 --- a/src/v2/product_service_client.ts +++ b/src/v2/product_service_client.ts @@ -645,6 +645,11 @@ export class ProductServiceClient { * * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error * is returned. + * + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. * @param {boolean} request.allowMissing * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not * found, a new {@link google.cloud.retail.v2.Product|Product} will be created. In @@ -836,7 +841,7 @@ export class ProductServiceClient { /** * Bulk import of multiple {@link google.cloud.retail.v2.Product|Product}s. * - * Request processing may be synchronous. No partial updating is supported. + * Request processing may be synchronous. * Non-existing items are created. * * Note that it is possible for a subset of the @@ -864,11 +869,18 @@ export class ProductServiceClient { * imported. Defaults to * {@link google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. * @param {string} request.notificationPubsubTopic - * Pub/Sub topic for receiving notification. If this field is set, + * Full Pub/Sub topic name for receiving notification. If this field is set, * when the import is finished, a notification will be sent to * specified Pub/Sub topic. The message data will be JSON string of a * {@link google.longrunning.Operation|Operation}. - * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * {@link google.cloud.retail.v2.ImportProductsRequest.parent|ImportProductsRequest.parent}. + * Make sure that both + * `cloud-retail-customer-data-access@system.gserviceaccount.com` and + * `service-@gcp-sa-retail.iam.gserviceaccount.com` + * have the `pubsub.topics.publish` IAM permission on the topic. * * Only supported when * {@link google.cloud.retail.v2.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} @@ -1038,7 +1050,7 @@ export class ProductServiceClient { * * Pre-existing inventory information can only be updated with * {@link google.cloud.retail.v2.ProductService.SetInventory|SetInventory}, - * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|AddFulfillmentPlaces}, + * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, * and * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|RemoveFulfillmentPlaces}. * @@ -1498,7 +1510,8 @@ export class ProductServiceClient { * If this field is set to an invalid value other than these, an * INVALID_ARGUMENT error is returned. * - * This field directly corresponds to {@link |Product.fulfillment_info.type}. + * This field directly corresponds to + * {@link google.cloud.retail.v2.FulfillmentInfo.type|Product.fulfillment_info.type}. * @param {string[]} request.placeIds * Required. The IDs for this * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}, such as diff --git a/src/v2/search_service_client.ts b/src/v2/search_service_client.ts index cf269f44..15c6c05e 100644 --- a/src/v2/search_service_client.ts +++ b/src/v2/search_service_client.ts @@ -331,7 +331,7 @@ export class SearchServiceClient { * The request object that will be sent. * @param {string} request.placement * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. * This field is used to identify the serving configuration name and the set * of models that will be used to make the search. * @param {string} request.branch @@ -342,6 +342,11 @@ export class SearchServiceClient { * products under the default branch. * @param {string} request.query * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. * @param {string} request.visitorId * Required. A unique identifier for tracking visitors. For example, this * could be implemented with an HTTP cookie, which should be able to uniquely @@ -424,10 +429,10 @@ export class SearchServiceClient { * [user guide](https://cloud.google.com/retail/docs/boosting). * * Notice that if both {@link |ServingConfig.boost_control_ids} and - * [SearchRequest.boost_spec] are set, the boost conditions from both places - * are evaluated. If a search request matches multiple boost conditions, - * the final boost score is equal to the sum of the boost scores from all - * matched boost conditions. + * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec * The query expansion specification that specifies the conditions under which * query expansion will occur. See more details at this [user @@ -460,7 +465,8 @@ export class SearchServiceClient { * * inventory(place_id,price) * * inventory(place_id,original_price) * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. + * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. * * attributes.key, where key is any key in the * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. * * pickupInStore.id, where id is any @@ -520,6 +526,27 @@ export class SearchServiceClient { * request triggers both product search and faceted search. * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec * The specification for personalization. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -606,7 +633,7 @@ export class SearchServiceClient { * The request object that will be sent. * @param {string} request.placement * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. * This field is used to identify the serving configuration name and the set * of models that will be used to make the search. * @param {string} request.branch @@ -617,6 +644,11 @@ export class SearchServiceClient { * products under the default branch. * @param {string} request.query * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. * @param {string} request.visitorId * Required. A unique identifier for tracking visitors. For example, this * could be implemented with an HTTP cookie, which should be able to uniquely @@ -699,10 +731,10 @@ export class SearchServiceClient { * [user guide](https://cloud.google.com/retail/docs/boosting). * * Notice that if both {@link |ServingConfig.boost_control_ids} and - * [SearchRequest.boost_spec] are set, the boost conditions from both places - * are evaluated. If a search request matches multiple boost conditions, - * the final boost score is equal to the sum of the boost scores from all - * matched boost conditions. + * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec * The query expansion specification that specifies the conditions under which * query expansion will occur. See more details at this [user @@ -735,7 +767,8 @@ export class SearchServiceClient { * * inventory(place_id,price) * * inventory(place_id,original_price) * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. + * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. * * attributes.key, where key is any key in the * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. * * pickupInStore.id, where id is any @@ -795,6 +828,27 @@ export class SearchServiceClient { * request triggers both product search and faceted search. * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec * The specification for personalization. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -837,7 +891,7 @@ export class SearchServiceClient { * The request object that will be sent. * @param {string} request.placement * Required. The resource name of the search engine placement, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search` + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. * This field is used to identify the serving configuration name and the set * of models that will be used to make the search. * @param {string} request.branch @@ -848,6 +902,11 @@ export class SearchServiceClient { * products under the default branch. * @param {string} request.query * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. * @param {string} request.visitorId * Required. A unique identifier for tracking visitors. For example, this * could be implemented with an HTTP cookie, which should be able to uniquely @@ -930,10 +989,10 @@ export class SearchServiceClient { * [user guide](https://cloud.google.com/retail/docs/boosting). * * Notice that if both {@link |ServingConfig.boost_control_ids} and - * [SearchRequest.boost_spec] are set, the boost conditions from both places - * are evaluated. If a search request matches multiple boost conditions, - * the final boost score is equal to the sum of the boost scores from all - * matched boost conditions. + * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec * The query expansion specification that specifies the conditions under which * query expansion will occur. See more details at this [user @@ -966,7 +1025,8 @@ export class SearchServiceClient { * * inventory(place_id,price) * * inventory(place_id,original_price) * * inventory(place_id,attributes.key), where key is any key in the - * {@link |Product.inventories.attributes} map. + * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. * * attributes.key, where key is any key in the * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. * * pickupInStore.id, where id is any @@ -1026,6 +1086,27 @@ export class SearchServiceClient { * request triggers both product search and faceted search. * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec * The specification for personalization. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object}